/*
 * Silicon labs si2176 Tuner Device Driver
 *
 * Author: Bobby Yang <bo.yang@amlogic.com>
 *
 *
 * Copyright (C) 2010 Amlogic Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */


/* Standard Liniux Headers */
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/delay.h>

/* Local Headers */
#include "si2176_func.h"


#define I2C_TRY_MAX_CNT       3  //max try counter

#ifdef CONFIG_MACH_MESON2_7366M_REFE01
#define SI2176_B2A
#else
#define SI2176_B30
#endif


#ifdef SI2176_B30
unsigned char firmwaretable[] = {
0x04,0x01,0x01,0x00,0xEE,0xA4,0xF3,0x6E,
0x0F,0x74,0xA9,0xF2,0x5C,0x9B,0x02,0xDB,
0x0F,0x15,0x15,0x1B,0xD9,0x4A,0x94,0x79,
0x05,0x5A,0x0A,0x7D,0xE7,0xDE,0x0E,0xBF,
0x22,0xE6,0x82,0x5B,0x50,0x2D,0xB6,0x3B,
0x07,0x86,0xA2,0x73,0xEC,0xFA,0x16,0x53,
0x05,0xD9,0xAD,0x33,0x43,0x27,0x56,0x7D,
0x22,0x6B,0xE2,0x86,0x56,0x29,0x36,0x5A,
0x05,0x6C,0xD1,0x6D,0x64,0x84,0x71,0xE1,
0x2A,0x8E,0x8C,0x59,0xAA,0x2C,0x85,0x2C,
0x05,0xCE,0xBA,0x9D,0x48,0x23,0xC7,0x6B,
0x2A,0x72,0x23,0xEB,0x90,0xDA,0xF2,0x11,
0x0F,0x1A,0x36,0xDA,0x66,0xD1,0xFA,0x07,
0x22,0xDA,0x72,0x94,0xBC,0xF3,0x0B,0x69,
0x05,0xBC,0xBC,0x11,0x4D,0xD5,0x0C,0xEE,
0x2F,0xF8,0xC9,0x55,0xB1,0xFC,0x4D,0x69,
0x27,0xC3,0xEB,0x0D,0x68,0xB6,0x76,0x8B,
0x2F,0x21,0xE5,0xBF,0xF6,0x00,0xA4,0x99,
0x2F,0x9E,0x3D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0xBF,0x4B,0x6C,0x23,
0x05,0xC1,0x85,0xC3,0x51,0xA4,0x19,0x8D,
0x24,0x22,0x37,0x37,0x15,0xC5,0x44,0x7F,
0x05,0x4F,0x39,0x79,0xF2,0x0E,0xB4,0xFD
};
#endif //SI2176_B30
#ifdef SI2176_B2A
unsigned char firmwaretable[] = {
0x04,0x01,0x80,0x4E,0x47,0x00,0xEA,0x87,
0x05,0xFC,0xF3,0x1D,0x24,0xC9,0xEE,0x2F,
0x05,0x21,0xF0,0x68,0xC6,0x5C,0x69,0x1D,
0x27,0xAD,0x67,0xFC,0xA0,0xAB,0x2B,0x9D,
0x07,0x6D,0x3D,0xCB,0xE9,0x62,0x00,0x0F,
0x2F,0xE4,0xC5,0xDA,0xD8,0xBA,0x4C,0x34,
0x07,0x67,0xF7,0x41,0x96,0x22,0x4A,0x41,
0x0F,0x73,0xC6,0x7C,0x8D,0x5C,0xD2,0xCC,
0x2F,0x92,0xB0,0x67,0x98,0x04,0xDD,0x3F,
0x2F,0x41,0xE3,0x47,0xE1,0xD4,0xC9,0x71,
0x2F,0xCA,0xBE,0x93,0x73,0x79,0xE9,0x46,
0x2F,0x2F,0x7E,0x62,0x5E,0xB1,0xD3,0x88,
0x2F,0x22,0xFE,0x0C,0x9D,0xD7,0x82,0x04,
0x0F,0x88,0x1B,0xD4,0xDA,0x70,0x75,0xF5,
0x25,0x7F,0x15,0x2C,0xF9,0x27,0xC3,0xC8,
0x0F,0xF5,0x2F,0x8D,0x69,0x85,0x79,0xB3,
0x2F,0x1F,0x48,0xB0,0x71,0xB7,0x08,0x3E,
0x2C,0xEC,0x6F,0x3B,0x7E,0xFA,0x1A,0x47,
0x07,0x89,0x75,0xF6,0xA3,0x1E,0x1E,0xD2,
0x07,0x8F,0xEB,0x75,0xC8,0x29,0x97,0xFC,
0x0F,0xD0,0x88,0x3E,0x10,0xE4,0xF9,0x6A,
0x27,0x30,0x92,0x85,0x3D,0xC0,0x80,0xD1,
0x2C,0x95,0x8B,0xE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x1E,0xDE,
0x0F,0x12,0xE6,0x38,0x5D,0xC7,0xAE,0x7B,
0x27,0xFA,0xED,0xCD,0x35,0x88,0x75,0x66,
0x27,0xA3,0xD4,0xE3,0x89,0x2C,0x6D,0x93,
0x2F,0x4A,0x78,0x7D,0x3A,0x0E,0xD3,0x89,
0x29,0x66,0x14,0x33,0x78,0x58,0xF9,0xC5,
0x07,0x91,0xC7,0x00,0x29,0xEB,0x8F,0x9C,
0x2F,0x48,0x78,0x21,0x76,0xDE,0x98,0x4F,
0x2F,0x3D,0x82,0xD2,0x95,0x79,0x48,0x13,
0x27,0xA4,0xCB,0x15,0xE1,0x05,0xCB,0xED,
0x2F,0x7A,0x7F,0x2B,0x61,0xEB,0x43,0xAC,
0x27,0xEF,0x82,0x8B,0xAF,0xDB,0x57,0x08,
0x2F,0x92,0xC9,0x6E,0x67,0xB5,0xC4,0x92,
0x27,0xE2,0x9B,0x76,0x75,0xC7,0x6E,0x19,
0x2F,0x66,0x54,0x44,0x3A,0x02,0x30,0x32,
0x27,0x66,0xB8,0x31,0x3B,0x3C,0x69,0x5E,
0x27,0xBC,0x94,0x12,0xE9,0x5D,0x19,0x69,
0x2F,0xD2,0xF8,0x54,0x7E,0xB4,0x81,0xD5,
0x23,0xE3,0x1A,0xC4,0x1E,0x5B,0x25,0x92,
0x07,0x3E,0xE3,0x43,0x13,0xEA,0xAF,0xEA,
0x2F,0xBD,0xAE,0x33,0x40,0x93,0x61,0x24,
0x07,0x03,0xD5,0x72,0xDD,0xAD,0x06,0x09,
0x27,0x13,0x7F,0x08,0xBA,0x60,0xCB,0x77,
0x2F,0xA0,0xFE,0x31,0x7B,0xCA,0x3D,0xCC,
0x27,0xDA,0xF1,0x43,0x40,0xDE,0xDD,0x63,
0x22,0x66,0x22,0x1E,0xE6,0x2F,0xBD,0x83,
0x07,0x7A,0x96,0xB7,0x14,0x87,0x90,0xD8,
0x27,0x50,0x06,0x1D,0xEC,0x35,0xF5,0xD3,
0x2F,0xCE,0x64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,0x75,0x0F,0x63,0xD9,
0x0F,0x25,0xA5,0xB5,0x01,0x3A,0x26,0xDA,
0x05,0x1B,0x0A,0x1D,0x20,0xF2,0x38,0x9E,
0x23,0x6A,0x71,0xE4,0xA2,0x7D,0x2B,0x71,
0x0F,0x7D,0x3C,0x42,0x97,0x87,0xE8,0xBA,
0x05,0x08,0x40,0xF8,0x74,0x55,0x88,0xB9
};
#endif //SI2176_B2A
#define NB_LINES (sizeof(firmwaretable)/(8*sizeof(unsigned char)))

//static unsigned char dlif_vidfilt_table[] = {0};

#define DLIF_VIDFILT_LINES (sizeof(dlif_vidfilt_table)/(8*sizeof(unsigned char)))

static si2176_common_reply_struct  reply;
/************************************************************************************************************************
  NAME:		   si2176_readcommandbytes function
  DESCRIPTION:Read inbbytes from the i2c device into pucdatabuffer, return number of bytes read
  Parameter: iI2CIndex, the index of the first byte to read.
  Parameter: inbbytes, the number of bytes to read.
  Parameter: *pucdatabuffer, a pointer to a buffer used to store the bytes
  Porting:    Replace with embedded system I2C read function
  Returns:    Actual number of bytes read.
************************************************************************************************************************/
static int si2176_readcommandbytes(struct i2c_client *si2176, int inbbytes, unsigned char *pucdatabuffer)
{
    int i2c_flag = 0;
    int i = 0;
    unsigned int i2c_try_cnt = I2C_TRY_MAX_CNT;

    struct i2c_msg msg[] = {
		{
			.addr	= si2176->addr,
			.flags	= I2C_M_RD,
			.len	= inbbytes,
			.buf	= pucdatabuffer,
        },
	};

repeat:
	i2c_flag = i2c_transfer(si2176->adapter, msg, 1);
    if (i2c_flag < 0) {
        pr_err("%s: error in read sli2176, %d byte(s) should be read,. \n", __func__, inbbytes);
        if (i++ < i2c_try_cnt) {
            pr_err("%s: error in read sli2176, try again!!!\n", __func__);
            goto repeat;
        }
        else
            return -EIO;
    }
    else {
        //pr_info("%s: read %d bytes\n", __func__, inbbytes);
        return inbbytes;
    }
}

/************************************************************************************************************************
  NAME:  si2176_writecommandbytes
  DESCRIPTION:  Write inbbytes from pucdatabuffer to the i2c device, return number of bytes written
  Porting:    Replace with inbbytes system I2C write function
  Returns:    Number of bytes written
************************************************************************************************************************/
static int si2176_writecommandbytes(struct i2c_client *si2176, int inbbytes, unsigned char *pucdatabuffer)
{
    int i2c_flag = 0;
    int i = 0;
    unsigned int i2c_try_cnt = I2C_TRY_MAX_CNT;

    struct i2c_msg msg[] = {
	    {
			.addr	= si2176->addr,
			.flags	= 0,    //|I2C_M_TEN,
			.len	= inbbytes,
			.buf	= pucdatabuffer,
		}

	};

repeat:
    i2c_flag = i2c_transfer(si2176->adapter, msg, 1);
    if (i2c_flag < 0) {
        pr_err("%s: error in write sli2176, %d byte(s) should be read,. \n", __func__, inbbytes);
        if (i++ < i2c_try_cnt) {
            pr_err("%s: error in wirte sli2176, try again!!!\n", __func__);
            goto repeat;
        }
        else
            return -EIO;
    }
    else {
        //pr_info("%s: write %d bytes\n", __func__, inbbytes);
        return inbbytes;
    }
}

/***********************************************************************************************************************
  sli2176_pollforcts function
  Use:        CTS checking function
              Used to check the CTS bit until it is set before sending the next command
  Comments:   The status byte definition being identical for all commands,
              using this function to fill the status structure hels reducing the code size
  Comments:   waitForCTS = 1 => I2C polling
              waitForCTS = 2 => INTB followed by a read (reading a HW byte using the cypress chip)
              max timeout = 100 ms

  Porting:    If reading INTB is not possible, the waitForCTS = 2 case can be removed

  Parameter: waitForCTS          a flag indicating if waiting for CTS is required
  Returns:   1 if the CTS bit is set, 0 otherwise
 ***********************************************************************************************************************/
static unsigned char si2176_pollforcts(struct i2c_client *si2176)
{
    unsigned char error_code = 0;
    unsigned char loop_count = 0;
    unsigned char rspbytebuffer[1];

    for (loop_count=0; loop_count<50; loop_count++) { /* wait a maximum of 50*25ms = 1.25s  */
        if (si2176_readcommandbytes(si2176, 1, rspbytebuffer) != 1)
            error_code = ERROR_SI2176_POLLING_CTS;
        else
            error_code = NO_SI2176_ERROR;
        if (error_code || (rspbytebuffer[0] & 0x80))
            goto exit;
        mdelay(2); /* CTS not set, wait 2ms and retry */
    }
    error_code = ERROR_SI2176_CTS_TIMEOUT;

exit:
    if (error_code)
        pr_info("%s: poll cts function error:%d!!!...............\n", __func__, error_code);

    return error_code;
}

/***********************************************************************************************************************
  SI2176_CurrentResponseStatus function
  Use:        status checking function
              Used to fill the SI2176_COMMON_REPLY_struct members with the ptDataBuffer byte's bits
  Comments:   The status byte definition being identical for all commands,
              using this function to fill the status structure hels reducing the code size

  Parameter: *ret          the SI2176_COMMON_REPLY_struct
  Parameter: ptDataBuffer  a single byte received when reading a command's response (the first byte)
  Returns:   0 if the err bit (bit 6) is unset, 1 otherwise
 ***********************************************************************************************************************/
static unsigned char si2176_currentresponsestatus(si2176_common_reply_struct *common_reply, unsigned char ptdatabuffer)
{
    /* _status_code_insertion_start */
    common_reply->tunint = ((ptdatabuffer >> 0 ) & 0x01);
    common_reply->atvint = ((ptdatabuffer >> 1 ) & 0x01);
    common_reply->dtvint = ((ptdatabuffer >> 2 ) & 0x01);
    common_reply->err    = ((ptdatabuffer >> 6 ) & 0x01);
    common_reply->cts    = ((ptdatabuffer >> 7 ) & 0x01);
    /* _status_code_insertion_point */
    return (common_reply->err ? ERROR_SI2176_ERR : NO_SI2176_ERROR);
}

/***********************************************************************************************************************
  si2176_pollforresponse function
  Use:        command response retrieval function
              Used to retrieve the command response in the provided buffer,
              poll for response either by I2C polling or wait for INTB
  Comments:   The status byte definition being identical for all commands,
              using this function to fill the status structure hels reducing the code size
  Comments:   waitForCTS = 1 => I2C polling
              waitForCTS = 2 => INTB followed by a read (reading a HW byte using the cypress chip)
              max timeout = 100 ms

  Porting:    If reading INTB is not possible, the waitForCTS = 2 case can be removed

  Parameter:  waitforresponse  a flag indicating if waiting for the response is required
  Parameter:  nbbytes          the number of response bytes to read
  Parameter:  pbytebuffer      a buffer into which bytes will be stored
  Returns:    0 if no error, an error code otherwise
 ***********************************************************************************************************************/
static unsigned char si2176_pollforresponse(struct i2c_client *si2176, unsigned char waitforresponse, unsigned int nbbytes, unsigned char *pbytebuffer, si2176_common_reply_struct *common_reply)
{
    unsigned char error_code;
    unsigned char loop_count;

    for (loop_count=0; loop_count<50; loop_count++) { /* wait a maximum of 50*2ms = 100ms                        */
        switch (waitforresponse) { /* type of response polling?                                */
            case 0 : /* no polling? valid option, but shouldn't have been called */
                error_code = NO_SI2176_ERROR; /* return no error                                          */
                goto exit;

            case 1 : /* I2C polling status?                                      */
                if (si2176_readcommandbytes(si2176, nbbytes, pbytebuffer) != nbbytes)
                    error_code = ERROR_SI2176_POLLING_RESPONSE;
                else
                    error_code = NO_SI2176_ERROR;
                if (error_code)
                    goto exit;	/* if error, exit with error code */
                if (pbytebuffer[0] & 0x80)	  /* CTS set? */
                {
                    error_code = si2176_currentresponsestatus(common_reply, pbytebuffer[0]);
                    goto exit; /* exit whether ERR set or not   */
                }
                break;

            default :
                error_code = ERROR_SI2176_PARAMETER_OUT_OF_RANGE; /* support debug of invalid CTS poll parameter   */
                goto exit;
        }
        mdelay(2); /* CTS not set, wait 2ms and retry                         */
    }
    error_code = ERROR_SI2176_CTS_TIMEOUT;

exit:
    return error_code;
}

/************************************************************************************************************************
  NAME: CheckStatus
  DESCRIPTION:     Read Si2170 STATUS byte and return decoded status
  Parameter:  Si2170 Context (I2C address)
  Parameter:  Status byte (TUNINT, ATVINT, DTVINT, ERR, CTS, CHLINT, and CHL flags).
  Returns:    Si2170/I2C transaction error code
************************************************************************************************************************/
#if 0
static int si2176_check_status(struct i2c_client *si2176, si2176_common_reply_struct *common_reply)
{
    unsigned char buffer[1];
	/* read STATUS byte */
    if (si2176_pollforresponse(si2176, 1, 1, buffer, common_reply) != 0)
	{
        return ERROR_SI2176_POLLING_RESPONSE;
    }

    return 0;
}
#endif
/***********************************************************************************************************************
  NAME: Si2170_L1_API_Patch
  DESCRIPTION: Patch information function
              Used to send a number of bytes to the Si2170. Useful to download the firmware.
  Parameter:   *api    a pointer to the api context to initialize
  Parameter:  waitForCTS flag for CTS checking prior to sending a Si2170 API Command
  Parameter:  waitForResponse flag for CTS checking and Response readback after sending Si2170 API Command
  Parameter:  number of bytes to transmit
  Parameter:  Databuffer containing the bytes to transfer in an unsigned char array.
  Returns:   0 if no error, else a nonzero int representing an error
 ***********************************************************************************************************************/
static unsigned char si2176_api_patch(struct i2c_client *si2176, int inbbytes, unsigned char *pucdatabuffer, si2176_common_reply_struct *common_reply)
{
    unsigned char res = 0;
    unsigned char error_code = 0;
    unsigned char rspbytebuffer[1];

    res = si2176_pollforcts(si2176);
    if (res != NO_SI2176_ERROR)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, res);
        return res;
    }

    res = si2176_writecommandbytes(si2176, inbbytes, pucdatabuffer);
    if (res!=inbbytes)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, ERROR_SI2176_SENDING_COMMAND);
       return ERROR_SI2176_SENDING_COMMAND;
    }

    error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, common_reply);
    if (error_code)
        pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);

    return error_code;
}


/* _commands_insertion_start */
#ifdef SI2176_AGC_OVERRIDE_CMD
/*---------------------------------------------------*/
/* SI2176_AGC_OVERRIDE COMMAND                     */
/*---------------------------------------------------*/
static unsigned char si2176_agc_override(struct i2c_client *si2176,
        unsigned char   force_max_gain,
        unsigned char   force_top_gain,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (force_max_gain > SI2176_AGC_OVERRIDE_CMD_FORCE_MAX_GAIN_MAX)
            || (force_top_gain > SI2176_AGC_OVERRIDE_CMD_FORCE_TOP_GAIN_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_AGC_OVERRIDE_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( force_max_gain & SI2176_AGC_OVERRIDE_CMD_FORCE_MAX_GAIN_MASK ) << SI2176_AGC_OVERRIDE_CMD_FORCE_MAX_GAIN_LSB|
                                         ( force_top_gain & SI2176_AGC_OVERRIDE_CMD_FORCE_TOP_GAIN_MASK ) << SI2176_AGC_OVERRIDE_CMD_FORCE_TOP_GAIN_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->agc_override.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_AGC_OVERRIDE_CMD */
#ifdef SI2176_ATV_CW_TEST_CMD
/*---------------------------------------------------*/
/* SI2176_ATV_CW_TEST COMMAND                      */
/*---------------------------------------------------*/
static unsigned char si2176_atv_cw_test(struct i2c_client *si2176,
        unsigned char   pc_lock,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (pc_lock > SI2176_ATV_CW_TEST_CMD_PC_LOCK_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code) goto exit;

    cmdbytebuffer[0] = SI2176_ATV_CW_TEST_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( pc_lock & SI2176_ATV_CW_TEST_CMD_PC_LOCK_MASK ) << SI2176_ATV_CW_TEST_CMD_PC_LOCK_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2) error_code = ERROR_SI2176_SENDING_COMMAND;

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->atv_cw_test.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_ATV_CW_TEST_CMD */
#ifdef SI2176_ATV_RESTART_CMD
/*---------------------------------------------------*/
/* SI2176_ATV_RESTART COMMAND                      */
/*---------------------------------------------------*/
static unsigned char si2176_atv_restart(struct i2c_client *si2176,
        unsigned char   mode,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (mode > SI2176_ATV_RESTART_CMD_MODE_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_ATV_RESTART_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( mode & SI2176_ATV_RESTART_CMD_MODE_MASK ) << SI2176_ATV_RESTART_CMD_MODE_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->atv_restart.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_ATV_RESTART_CMD */
#ifdef SI2176_ATV_STATUS_CMD
/*---------------------------------------------------*/
/* SI2176_ATV_STATUS COMMAND                       */
/*---------------------------------------------------*/
unsigned char si2176_atv_status(struct i2c_client *si2176,
        unsigned char intack,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[11];

#ifdef DEBUG_RANGE_CHECK
    if ( (intack > SI2176_ATV_STATUS_CMD_INTACK_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_ATV_STATUS_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( intack & SI2176_ATV_STATUS_CMD_INTACK_MASK ) << SI2176_ATV_STATUS_CMD_INTACK_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 11, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->atv_status.status = &reply;
        if (!error_code)
        {
            rsp->atv_status.chlint           =   (( ( (rspbytebuffer[1]  )) >> SI2176_ATV_STATUS_RESPONSE_CHLINT_LSB           ) & SI2176_ATV_STATUS_RESPONSE_CHLINT_MASK           );
            rsp->atv_status.pclint           =   (( ( (rspbytebuffer[1]  )) >> SI2176_ATV_STATUS_RESPONSE_PCLINT_LSB           ) & SI2176_ATV_STATUS_RESPONSE_PCLINT_MASK           );
            rsp->atv_status.dlint            =   (( ( (rspbytebuffer[1]  )) >> SI2176_ATV_STATUS_RESPONSE_DLINT_LSB            ) & SI2176_ATV_STATUS_RESPONSE_DLINT_MASK            );
            rsp->atv_status.snrlint          =   (( ( (rspbytebuffer[1]  )) >> SI2176_ATV_STATUS_RESPONSE_SNRLINT_LSB          ) & SI2176_ATV_STATUS_RESPONSE_SNRLINT_MASK          );
            rsp->atv_status.snrhint          =   (( ( (rspbytebuffer[1]  )) >> SI2176_ATV_STATUS_RESPONSE_SNRHINT_LSB          ) & SI2176_ATV_STATUS_RESPONSE_SNRHINT_MASK          );
            rsp->atv_status.chl              =   (( ( (rspbytebuffer[2]  )) >> SI2176_ATV_STATUS_RESPONSE_CHL_LSB              ) & SI2176_ATV_STATUS_RESPONSE_CHL_MASK              );
            rsp->atv_status.pcl              =   (( ( (rspbytebuffer[2]  )) >> SI2176_ATV_STATUS_RESPONSE_PCL_LSB              ) & SI2176_ATV_STATUS_RESPONSE_PCL_MASK              );
            rsp->atv_status.dl               =   (( ( (rspbytebuffer[2]  )) >> SI2176_ATV_STATUS_RESPONSE_DL_LSB               ) & SI2176_ATV_STATUS_RESPONSE_DL_MASK               );
            rsp->atv_status.snrl             =   (( ( (rspbytebuffer[2]  )) >> SI2176_ATV_STATUS_RESPONSE_SNRL_LSB             ) & SI2176_ATV_STATUS_RESPONSE_SNRL_MASK             );
            rsp->atv_status.snrh             =   (( ( (rspbytebuffer[2]  )) >> SI2176_ATV_STATUS_RESPONSE_SNRH_LSB             ) & SI2176_ATV_STATUS_RESPONSE_SNRH_MASK             );
            rsp->atv_status.video_snr        =   (( ( (rspbytebuffer[3]  )) >> SI2176_ATV_STATUS_RESPONSE_VIDEO_SNR_LSB        ) & SI2176_ATV_STATUS_RESPONSE_VIDEO_SNR_MASK        );
            rsp->atv_status.afc_freq         = (((( ( (rspbytebuffer[4]  ) | (rspbytebuffer[5]  << 8 )) >> SI2176_ATV_STATUS_RESPONSE_AFC_FREQ_LSB         ) & SI2176_ATV_STATUS_RESPONSE_AFC_FREQ_MASK) <<SI2176_ATV_STATUS_RESPONSE_AFC_FREQ_SHIFT ) >>SI2176_ATV_STATUS_RESPONSE_AFC_FREQ_SHIFT         );
            rsp->atv_status.video_sc_spacing = (((( ( (rspbytebuffer[6]  ) | (rspbytebuffer[7]  << 8 )) >> SI2176_ATV_STATUS_RESPONSE_VIDEO_SC_SPACING_LSB ) & SI2176_ATV_STATUS_RESPONSE_VIDEO_SC_SPACING_MASK) <<SI2176_ATV_STATUS_RESPONSE_VIDEO_SC_SPACING_SHIFT ) >>SI2176_ATV_STATUS_RESPONSE_VIDEO_SC_SPACING_SHIFT );
            rsp->atv_status.video_sys        =   (( ( (rspbytebuffer[8]  )) >> SI2176_ATV_STATUS_RESPONSE_VIDEO_SYS_LSB        ) & SI2176_ATV_STATUS_RESPONSE_VIDEO_SYS_MASK        );
            rsp->atv_status.color            =   (( ( (rspbytebuffer[8]  )) >> SI2176_ATV_STATUS_RESPONSE_COLOR_LSB            ) & SI2176_ATV_STATUS_RESPONSE_COLOR_MASK            );
            rsp->atv_status.trans            =   (( ( (rspbytebuffer[8]  )) >> SI2176_ATV_STATUS_RESPONSE_TRANS_LSB            ) & SI2176_ATV_STATUS_RESPONSE_TRANS_MASK            );
            rsp->atv_status.audio_sys        =   (( ( (rspbytebuffer[9]  )) >> SI2176_ATV_STATUS_RESPONSE_AUDIO_SYS_LSB        ) & SI2176_ATV_STATUS_RESPONSE_AUDIO_SYS_MASK        );
            rsp->atv_status.audio_demod_mode =   (( ( (rspbytebuffer[9]  )) >> SI2176_ATV_STATUS_RESPONSE_AUDIO_DEMOD_MODE_LSB ) & SI2176_ATV_STATUS_RESPONSE_AUDIO_DEMOD_MODE_MASK );
            rsp->atv_status.audio_chan_bw    =   (( ( (rspbytebuffer[10] )) >> SI2176_ATV_STATUS_RESPONSE_AUDIO_CHAN_BW_LSB    ) & SI2176_ATV_STATUS_RESPONSE_AUDIO_CHAN_BW_MASK    );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_ATV_STATUS_CMD */
#ifdef SI2176_CONFIG_PINS_CMD
/*---------------------------------------------------*/
/* SI2176_CONFIG_PINS COMMAND                      */
/*---------------------------------------------------*/
static unsigned char si2176_config_pins(struct i2c_client *si2176,
        unsigned char   gpio1_mode,
        unsigned char   gpio1_read,
        unsigned char   gpio2_mode,
        unsigned char   gpio2_read,
        unsigned char   gpio3_mode,
        unsigned char   gpio3_read,
        unsigned char   bclk1_mode,
        unsigned char   bclk1_read,
        unsigned char   xout_mode,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[6];
    unsigned char rspbytebuffer[6];

#ifdef DEBUG_RANGE_CHECK
    if ( (gpio1_mode > SI2176_CONFIG_PINS_CMD_GPIO1_MODE_MAX)
            || (gpio1_read > SI2176_CONFIG_PINS_CMD_GPIO1_READ_MAX)
            || (gpio2_mode > SI2176_CONFIG_PINS_CMD_GPIO2_MODE_MAX)
            || (gpio2_read > SI2176_CONFIG_PINS_CMD_GPIO2_READ_MAX)
            || (gpio3_mode > SI2176_CONFIG_PINS_CMD_GPIO3_MODE_MAX)
            || (gpio3_read > SI2176_CONFIG_PINS_CMD_GPIO3_READ_MAX)
            || (bclk1_mode > SI2176_CONFIG_PINS_CMD_BCLK1_MODE_MAX)
            || (bclk1_read > SI2176_CONFIG_PINS_CMD_BCLK1_READ_MAX)
            || (xout_mode  > SI2176_CONFIG_PINS_CMD_XOUT_MODE_MAX ) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_CONFIG_PINS_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( gpio1_mode & SI2176_CONFIG_PINS_CMD_GPIO1_MODE_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO1_MODE_LSB|
                                         ( gpio1_read & SI2176_CONFIG_PINS_CMD_GPIO1_READ_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO1_READ_LSB);
    cmdbytebuffer[2] = (unsigned char) ( ( gpio2_mode & SI2176_CONFIG_PINS_CMD_GPIO2_MODE_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO2_MODE_LSB|
                                         ( gpio2_read & SI2176_CONFIG_PINS_CMD_GPIO2_READ_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO2_READ_LSB);
    cmdbytebuffer[3] = (unsigned char) ( ( gpio3_mode & SI2176_CONFIG_PINS_CMD_GPIO3_MODE_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO3_MODE_LSB|
                                         ( gpio3_read & SI2176_CONFIG_PINS_CMD_GPIO3_READ_MASK ) << SI2176_CONFIG_PINS_CMD_GPIO3_READ_LSB);
    cmdbytebuffer[4] = (unsigned char) ( ( bclk1_mode & SI2176_CONFIG_PINS_CMD_BCLK1_MODE_MASK ) << SI2176_CONFIG_PINS_CMD_BCLK1_MODE_LSB|
                                         ( bclk1_read & SI2176_CONFIG_PINS_CMD_BCLK1_READ_MASK ) << SI2176_CONFIG_PINS_CMD_BCLK1_READ_LSB);
    cmdbytebuffer[5] = (unsigned char) ( ( xout_mode  & SI2176_CONFIG_PINS_CMD_XOUT_MODE_MASK  ) << SI2176_CONFIG_PINS_CMD_XOUT_MODE_LSB );

    if (si2176_writecommandbytes(si2176, 6, cmdbytebuffer) != 6)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 6, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->config_pins.status = &reply;
        if (!error_code)
        {
            rsp->config_pins.gpio1_mode  =   (( ( (rspbytebuffer[1]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO1_MODE_LSB  ) & SI2176_CONFIG_PINS_RESPONSE_GPIO1_MODE_MASK  );
            rsp->config_pins.gpio1_state =   (( ( (rspbytebuffer[1]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO1_STATE_LSB ) & SI2176_CONFIG_PINS_RESPONSE_GPIO1_STATE_MASK );
            rsp->config_pins.gpio2_mode  =   (( ( (rspbytebuffer[2]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO2_MODE_LSB  ) & SI2176_CONFIG_PINS_RESPONSE_GPIO2_MODE_MASK  );
            rsp->config_pins.gpio2_state =   (( ( (rspbytebuffer[2]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO2_STATE_LSB ) & SI2176_CONFIG_PINS_RESPONSE_GPIO2_STATE_MASK );
            rsp->config_pins.gpio3_mode  =   (( ( (rspbytebuffer[3]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO3_MODE_LSB  ) & SI2176_CONFIG_PINS_RESPONSE_GPIO3_MODE_MASK  );
            rsp->config_pins.gpio3_state =   (( ( (rspbytebuffer[3]  )) >> SI2176_CONFIG_PINS_RESPONSE_GPIO3_STATE_LSB ) & SI2176_CONFIG_PINS_RESPONSE_GPIO3_STATE_MASK );
            rsp->config_pins.bclk1_mode  =   (( ( (rspbytebuffer[4]  )) >> SI2176_CONFIG_PINS_RESPONSE_BCLK1_MODE_LSB  ) & SI2176_CONFIG_PINS_RESPONSE_BCLK1_MODE_MASK  );
            rsp->config_pins.bclk1_state =   (( ( (rspbytebuffer[4]  )) >> SI2176_CONFIG_PINS_RESPONSE_BCLK1_STATE_LSB ) & SI2176_CONFIG_PINS_RESPONSE_BCLK1_STATE_MASK );
            rsp->config_pins.xout_mode   =   (( ( (rspbytebuffer[5]  )) >> SI2176_CONFIG_PINS_RESPONSE_XOUT_MODE_LSB   ) & SI2176_CONFIG_PINS_RESPONSE_XOUT_MODE_MASK   );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_CONFIG_PINS_CMD */
#ifdef SI2176_EXIT_BOOTLOADER_CMD
/*---------------------------------------------------*/
/* SI2176_EXIT_BOOTLOADER COMMAND                  */
/*---------------------------------------------------*/
static unsigned char si2176_exit_bootloader(struct i2c_client *si2176,
        unsigned char   func,
        unsigned char   ctsien,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (func   > SI2176_EXIT_BOOTLOADER_CMD_FUNC_MAX  )
            || (ctsien > SI2176_EXIT_BOOTLOADER_CMD_CTSIEN_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code) goto exit;

    cmdbytebuffer[0] = SI2176_EXIT_BOOTLOADER_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( func   & SI2176_EXIT_BOOTLOADER_CMD_FUNC_MASK   ) << SI2176_EXIT_BOOTLOADER_CMD_FUNC_LSB  |
                                         ( ctsien & SI2176_EXIT_BOOTLOADER_CMD_CTSIEN_MASK ) << SI2176_EXIT_BOOTLOADER_CMD_CTSIEN_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2) error_code = ERROR_SI2176_SENDING_COMMAND;

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->exit_bootloader.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_EXIT_BOOTLOADER_CMD */
#ifdef SI2176_FINE_TUNE_CMD
/*---------------------------------------------------*/
/* SI2176_FINE_TUNE COMMAND                        */
/*---------------------------------------------------*/
static unsigned char si2176_fine_tune(struct i2c_client *si2176,
        unsigned char   reserved,
        int   offset_500hz,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[4];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (reserved     > SI2176_FINE_TUNE_CMD_RESERVED_MAX    )
            || (offset_500hz > SI2176_FINE_TUNE_CMD_OFFSET_500HZ_MAX)  || (offset_500hz < SI2176_FINE_TUNE_CMD_OFFSET_500HZ_MIN) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_FINE_TUNE_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( reserved     & SI2176_FINE_TUNE_CMD_RESERVED_MASK     ) << SI2176_FINE_TUNE_CMD_RESERVED_LSB    );
    cmdbytebuffer[2] = (unsigned char) ( ( offset_500hz & SI2176_FINE_TUNE_CMD_OFFSET_500HZ_MASK ) << SI2176_FINE_TUNE_CMD_OFFSET_500HZ_LSB);
    cmdbytebuffer[3] = (unsigned char) ((( offset_500hz & SI2176_FINE_TUNE_CMD_OFFSET_500HZ_MASK ) << SI2176_FINE_TUNE_CMD_OFFSET_500HZ_LSB)>>8);

    if (si2176_writecommandbytes(si2176, 4, cmdbytebuffer) != 4)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->fine_tune.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_FINE_TUNE_CMD */
#ifdef SI2176_GET_PROPERTY_CMD
/*---------------------------------------------------*/
/* SI2176_GET_PROPERTY COMMAND                     */
/*---------------------------------------------------*/
static unsigned char si2176_get_property(struct i2c_client *si2176,
        unsigned char   reserved,
        unsigned int    prop,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[4];
    unsigned char rspbytebuffer[4];

#ifdef DEBUG_RANGE_CHECK
    if ( (reserved > SI2176_GET_PROPERTY_CMD_RESERVED_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_GET_PROPERTY_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( reserved & SI2176_GET_PROPERTY_CMD_RESERVED_MASK ) << SI2176_GET_PROPERTY_CMD_RESERVED_LSB);
    cmdbytebuffer[2] = (unsigned char) ( ( prop     & SI2176_GET_PROPERTY_CMD_PROP_MASK     ) << SI2176_GET_PROPERTY_CMD_PROP_LSB    );
    cmdbytebuffer[3] = (unsigned char) ((( prop     & SI2176_GET_PROPERTY_CMD_PROP_MASK     ) << SI2176_GET_PROPERTY_CMD_PROP_LSB    )>>8);

    if (si2176_writecommandbytes(si2176, 4, cmdbytebuffer) != 4)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 4, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->get_property.status = &reply;
        if (!error_code)
        {
            rsp->get_property.reserved =   (( ( (rspbytebuffer[1]  )) >> SI2176_GET_PROPERTY_RESPONSE_RESERVED_LSB ) & SI2176_GET_PROPERTY_RESPONSE_RESERVED_MASK );
            rsp->get_property.data     =   (( ( (rspbytebuffer[2]  ) | (rspbytebuffer[3]  << 8 )) >> SI2176_GET_PROPERTY_RESPONSE_DATA_LSB     ) & SI2176_GET_PROPERTY_RESPONSE_DATA_MASK     );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_GET_PROPERTY_CMD */
#ifdef SI2176_GET_REV_CMD
/*---------------------------------------------------*/
/* SI2176_GET_REV COMMAND                          */
/*---------------------------------------------------*/
static unsigned char si2176_get_rev(struct i2c_client *si2176,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[1];
    unsigned char rspbytebuffer[10];

    error_code = si2176_pollforcts(si2176);
    if (error_code) goto exit;

    cmdbytebuffer[0] = SI2176_GET_REV_CMD;

    if (si2176_writecommandbytes(si2176, 1, cmdbytebuffer) != 1) error_code = ERROR_SI2176_SENDING_COMMAND;

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 10, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->get_rev.status = &reply;
        if (!error_code)
        {
            rsp->get_rev.pn       =   (( ( (rspbytebuffer[1]  )) >> SI2176_GET_REV_RESPONSE_PN_LSB       ) & SI2176_GET_REV_RESPONSE_PN_MASK       );
            rsp->get_rev.fwmajor  =   (( ( (rspbytebuffer[2]  )) >> SI2176_GET_REV_RESPONSE_FWMAJOR_LSB  ) & SI2176_GET_REV_RESPONSE_FWMAJOR_MASK  );
            rsp->get_rev.fwminor  =   (( ( (rspbytebuffer[3]  )) >> SI2176_GET_REV_RESPONSE_FWMINOR_LSB  ) & SI2176_GET_REV_RESPONSE_FWMINOR_MASK  );
            rsp->get_rev.patch    =   (( ( (rspbytebuffer[4]  ) | (rspbytebuffer[5]  << 8 )) >> SI2176_GET_REV_RESPONSE_PATCH_LSB    ) & SI2176_GET_REV_RESPONSE_PATCH_MASK    );
            rsp->get_rev.cmpmajor =   (( ( (rspbytebuffer[6]  )) >> SI2176_GET_REV_RESPONSE_CMPMAJOR_LSB ) & SI2176_GET_REV_RESPONSE_CMPMAJOR_MASK );
            rsp->get_rev.cmpminor =   (( ( (rspbytebuffer[7]  )) >> SI2176_GET_REV_RESPONSE_CMPMINOR_LSB ) & SI2176_GET_REV_RESPONSE_CMPMINOR_MASK );
            rsp->get_rev.cmpbuild =   (( ( (rspbytebuffer[8]  )) >> SI2176_GET_REV_RESPONSE_CMPBUILD_LSB ) & SI2176_GET_REV_RESPONSE_CMPBUILD_MASK );
            rsp->get_rev.chiprev  =   (( ( (rspbytebuffer[9]  )) >> SI2176_GET_REV_RESPONSE_CHIPREV_LSB  ) & SI2176_GET_REV_RESPONSE_CHIPREV_MASK  );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_GET_REV_CMD */
#ifdef SI2176_PART_INFO_CMD
/*---------------------------------------------------*/
/* SI2176_PART_INFO COMMAND                        */
/*---------------------------------------------------*/
static unsigned char si2176_part_info(struct i2c_client *si2176,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[1];
    unsigned char rspbytebuffer[13];

    error_code = si2176_pollforcts(si2176);
    if (error_code) goto exit;

    cmdbytebuffer[0] = SI2176_PART_INFO_CMD;

    if (si2176_writecommandbytes(si2176, 1, cmdbytebuffer) != 1) error_code = ERROR_SI2176_SENDING_COMMAND;

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 13, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->part_info.status = &reply;
        if (!error_code)
        {
            rsp->part_info.chiprev  =   (( ( (rspbytebuffer[1]  )) >> SI2176_PART_INFO_RESPONSE_CHIPREV_LSB  ) & SI2176_PART_INFO_RESPONSE_CHIPREV_MASK  );
            rsp->part_info.part     =   (( ( (rspbytebuffer[2]  )) >> SI2176_PART_INFO_RESPONSE_PART_LSB     ) & SI2176_PART_INFO_RESPONSE_PART_MASK     );
            rsp->part_info.pmajor   =   (( ( (rspbytebuffer[3]  )) >> SI2176_PART_INFO_RESPONSE_PMAJOR_LSB   ) & SI2176_PART_INFO_RESPONSE_PMAJOR_MASK   );
            rsp->part_info.pminor   =   (( ( (rspbytebuffer[4]  )) >> SI2176_PART_INFO_RESPONSE_PMINOR_LSB   ) & SI2176_PART_INFO_RESPONSE_PMINOR_MASK   );
            rsp->part_info.pbuild   =   (( ( (rspbytebuffer[5]  )) >> SI2176_PART_INFO_RESPONSE_PBUILD_LSB   ) & SI2176_PART_INFO_RESPONSE_PBUILD_MASK   );
            rsp->part_info.reserved =   (( ( (rspbytebuffer[6]  ) | (rspbytebuffer[7]  << 8 )) >> SI2176_PART_INFO_RESPONSE_RESERVED_LSB ) & SI2176_PART_INFO_RESPONSE_RESERVED_MASK );
            rsp->part_info.serial   =   (( ( (rspbytebuffer[8]  ) | (rspbytebuffer[9]  << 8 ) | (rspbytebuffer[10] << 16 ) | (rspbytebuffer[11] << 24 )) >> SI2176_PART_INFO_RESPONSE_SERIAL_LSB   ) & SI2176_PART_INFO_RESPONSE_SERIAL_MASK   );
            rsp->part_info.romid    =   (( ( (rspbytebuffer[12] )) >> SI2176_PART_INFO_RESPONSE_ROMID_LSB    ) & SI2176_PART_INFO_RESPONSE_ROMID_MASK    );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_PART_INFO_CMD */
#ifdef SI2176_POWER_DOWN_CMD
/*---------------------------------------------------*/
/* SI2176_POWER_DOWN COMMAND                       */
/*---------------------------------------------------*/
static unsigned char si2176_power_down(struct i2c_client *si2176,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[1];
    unsigned char rspbytebuffer[1];

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_POWER_DOWN_CMD;

    if (si2176_writecommandbytes(si2176, 1, cmdbytebuffer) != 1)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->power_down.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_POWER_DOWN_CMD */
#ifdef SI2176_POWER_UP_CMD
/*---------------------------------------------------*/
/* SI2176_POWER_UP COMMAND                         */
/*---------------------------------------------------*/
static unsigned char si2176_power_up(struct i2c_client *si2176,
        unsigned char   subcode,
        unsigned char   reserved1,
        unsigned char   reserved2,
        unsigned char   reserved3,
        unsigned char   clock_mode,
        unsigned char   clock_freq,
        unsigned char   addr_mode,
        unsigned char   func,
        unsigned char   ctsien,
        unsigned char   wake_up,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[9];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (subcode    > SI2176_POWER_UP_CMD_SUBCODE_MAX   )  || (subcode    < SI2176_POWER_UP_CMD_SUBCODE_MIN   )
            || (reserved1  > SI2176_POWER_UP_CMD_RESERVED1_MAX )  || (reserved1  < SI2176_POWER_UP_CMD_RESERVED1_MIN )
            || (reserved2  > SI2176_POWER_UP_CMD_RESERVED2_MAX )
            || (reserved3  > SI2176_POWER_UP_CMD_RESERVED3_MAX )
            || (clock_mode > SI2176_POWER_UP_CMD_CLOCK_MODE_MAX)  || (clock_mode < SI2176_POWER_UP_CMD_CLOCK_MODE_MIN)
            || (clock_freq > SI2176_POWER_UP_CMD_CLOCK_FREQ_MAX)
            || (addr_mode  > SI2176_POWER_UP_CMD_ADDR_MODE_MAX )
            || (func       > SI2176_POWER_UP_CMD_FUNC_MAX      )
            || (ctsien     > SI2176_POWER_UP_CMD_CTSIEN_MAX    )
            || (wake_up    > SI2176_POWER_UP_CMD_WAKE_UP_MAX   )  || (wake_up    < SI2176_POWER_UP_CMD_WAKE_UP_MIN   ) )

    {
    	if(SI2176_DEBUG)
        	pr_info("%s: DEBUG_RANGE_CHECK!!!!\n", __func__);
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
    }
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_POWER_UP_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( subcode    & SI2176_POWER_UP_CMD_SUBCODE_MASK    ) << SI2176_POWER_UP_CMD_SUBCODE_LSB   );
    cmdbytebuffer[2] = (unsigned char) ( ( reserved1  & SI2176_POWER_UP_CMD_RESERVED1_MASK  ) << SI2176_POWER_UP_CMD_RESERVED1_LSB );
    cmdbytebuffer[3] = (unsigned char) ( ( reserved2  & SI2176_POWER_UP_CMD_RESERVED2_MASK  ) << SI2176_POWER_UP_CMD_RESERVED2_LSB );
    cmdbytebuffer[4] = (unsigned char) ( ( reserved3  & SI2176_POWER_UP_CMD_RESERVED3_MASK  ) << SI2176_POWER_UP_CMD_RESERVED3_LSB );
    cmdbytebuffer[5] = (unsigned char) ( ( clock_mode & SI2176_POWER_UP_CMD_CLOCK_MODE_MASK ) << SI2176_POWER_UP_CMD_CLOCK_MODE_LSB|
                                         ( clock_freq & SI2176_POWER_UP_CMD_CLOCK_FREQ_MASK ) << SI2176_POWER_UP_CMD_CLOCK_FREQ_LSB);
    cmdbytebuffer[6] = (unsigned char) ( ( addr_mode  & SI2176_POWER_UP_CMD_ADDR_MODE_MASK  ) << SI2176_POWER_UP_CMD_ADDR_MODE_LSB );
    cmdbytebuffer[7] = (unsigned char) ( ( func       & SI2176_POWER_UP_CMD_FUNC_MASK       ) << SI2176_POWER_UP_CMD_FUNC_LSB      |
                                         ( ctsien     & SI2176_POWER_UP_CMD_CTSIEN_MASK     ) << SI2176_POWER_UP_CMD_CTSIEN_LSB    );
    cmdbytebuffer[8] = (unsigned char) ( ( wake_up    & SI2176_POWER_UP_CMD_WAKE_UP_MASK    ) << SI2176_POWER_UP_CMD_WAKE_UP_LSB   );

    if (si2176_writecommandbytes(si2176, 9, cmdbytebuffer) != 9)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        if (error_code)
            pr_info("%s: si2176_writecommandbytes!!!!\n", __func__);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);

        rsp->power_up.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_POWER_UP_CMD */
#ifdef SI2176_SET_PROPERTY_CMD
/*---------------------------------------------------*/
/* SI2176_SET_PROPERTY COMMAND                     */
/*---------------------------------------------------*/
static unsigned char si2176_set_property(struct i2c_client *si2176,
        unsigned char   reserved,
        unsigned int    prop,
        unsigned int    data,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[6];
    unsigned char rspbytebuffer[4];

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_SET_PROPERTY_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( reserved & SI2176_SET_PROPERTY_CMD_RESERVED_MASK ) << SI2176_SET_PROPERTY_CMD_RESERVED_LSB);
    cmdbytebuffer[2] = (unsigned char) ( ( prop     & SI2176_SET_PROPERTY_CMD_PROP_MASK     ) << SI2176_SET_PROPERTY_CMD_PROP_LSB    );
    cmdbytebuffer[3] = (unsigned char) ((( prop     & SI2176_SET_PROPERTY_CMD_PROP_MASK     ) << SI2176_SET_PROPERTY_CMD_PROP_LSB    )>>8);
    cmdbytebuffer[4] = (unsigned char) ( ( data     & SI2176_SET_PROPERTY_CMD_DATA_MASK     ) << SI2176_SET_PROPERTY_CMD_DATA_LSB    );
    cmdbytebuffer[5] = (unsigned char) ((( data     & SI2176_SET_PROPERTY_CMD_DATA_MASK     ) << SI2176_SET_PROPERTY_CMD_DATA_LSB    )>>8);

    if (si2176_writecommandbytes(si2176, 6, cmdbytebuffer) != 6)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 4, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->set_property.status = &reply;
        if (!error_code)
        {
            rsp->set_property.reserved =   (( ( (rspbytebuffer[1]  )) >> SI2176_SET_PROPERTY_RESPONSE_RESERVED_LSB ) & SI2176_SET_PROPERTY_RESPONSE_RESERVED_MASK );
            rsp->set_property.data     =   (( ( (rspbytebuffer[2]  ) | (rspbytebuffer[3]  << 8 )) >> SI2176_SET_PROPERTY_RESPONSE_DATA_LSB     ) & SI2176_SET_PROPERTY_RESPONSE_DATA_MASK     );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_SET_PROPERTY_CMD */
#ifdef SI2176_STANDBY_CMD
/*---------------------------------------------------*/
/* SI2176_STANDBY COMMAND                          */
/*---------------------------------------------------*/
static unsigned char si2176_standby(struct i2c_client *si2176,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[1];
    unsigned char rspbytebuffer[1];

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_STANDBY_CMD;

    if (si2176_writecommandbytes(si2176, 1, cmdbytebuffer) != 1)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->standby.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_STANDBY_CMD */
#ifdef SI2176_TUNER_STATUS_CMD
/*---------------------------------------------------*/
/* SI2176_TUNER_STATUS COMMAND                     */
/*---------------------------------------------------*/
unsigned char si2176_tuner_status(struct i2c_client *si2176,
        unsigned char   intack,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[2];
    unsigned char rspbytebuffer[12];

#ifdef DEBUG_RANGE_CHECK
    if ( (intack > SI2176_TUNER_STATUS_CMD_INTACK_MAX) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_TUNER_STATUS_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( intack & SI2176_TUNER_STATUS_CMD_INTACK_MASK ) << SI2176_TUNER_STATUS_CMD_INTACK_LSB);

    if (si2176_writecommandbytes(si2176, 2, cmdbytebuffer) != 2)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 12, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->tuner_status.status = &reply;
        if (!error_code)
        {
            rsp->tuner_status.tcint    =   (( ( (rspbytebuffer[1]  )) >> SI2176_TUNER_STATUS_RESPONSE_TCINT_LSB    ) & SI2176_TUNER_STATUS_RESPONSE_TCINT_MASK    );
            rsp->tuner_status.rssilint =   (( ( (rspbytebuffer[1]  )) >> SI2176_TUNER_STATUS_RESPONSE_RSSILINT_LSB ) & SI2176_TUNER_STATUS_RESPONSE_RSSILINT_MASK );
            rsp->tuner_status.rssihint =   (( ( (rspbytebuffer[1]  )) >> SI2176_TUNER_STATUS_RESPONSE_RSSIHINT_LSB ) & SI2176_TUNER_STATUS_RESPONSE_RSSIHINT_MASK );
            rsp->tuner_status.tc       =   (( ( (rspbytebuffer[2]  )) >> SI2176_TUNER_STATUS_RESPONSE_TC_LSB       ) & SI2176_TUNER_STATUS_RESPONSE_TC_MASK       );
            rsp->tuner_status.rssil    =   (( ( (rspbytebuffer[2]  )) >> SI2176_TUNER_STATUS_RESPONSE_RSSIL_LSB    ) & SI2176_TUNER_STATUS_RESPONSE_RSSIL_MASK    );
            rsp->tuner_status.rssih    =   (( ( (rspbytebuffer[2]  )) >> SI2176_TUNER_STATUS_RESPONSE_RSSIH_LSB    ) & SI2176_TUNER_STATUS_RESPONSE_RSSIH_MASK    );
            rsp->tuner_status.rssi     = (((( ( (rspbytebuffer[3]  )) >> SI2176_TUNER_STATUS_RESPONSE_RSSI_LSB     ) & SI2176_TUNER_STATUS_RESPONSE_RSSI_MASK) <<SI2176_TUNER_STATUS_RESPONSE_RSSI_SHIFT ) >>SI2176_TUNER_STATUS_RESPONSE_RSSI_SHIFT     );
            rsp->tuner_status.freq     =   (( ( (rspbytebuffer[4]  ) | (rspbytebuffer[5]  << 8 ) | (rspbytebuffer[6]  << 16 ) | (rspbytebuffer[7]  << 24 )) >> SI2176_TUNER_STATUS_RESPONSE_FREQ_LSB     ) & SI2176_TUNER_STATUS_RESPONSE_FREQ_MASK     );
            rsp->tuner_status.mode     =   (( ( (rspbytebuffer[8]  )) >> SI2176_TUNER_STATUS_RESPONSE_MODE_LSB     ) & SI2176_TUNER_STATUS_RESPONSE_MODE_MASK     );
            rsp->tuner_status.vco_code = (((( ( (rspbytebuffer[10] ) | (rspbytebuffer[11] << 8 )) >> SI2176_TUNER_STATUS_RESPONSE_VCO_CODE_LSB ) & SI2176_TUNER_STATUS_RESPONSE_VCO_CODE_MASK) <<SI2176_TUNER_STATUS_RESPONSE_VCO_CODE_SHIFT ) >>SI2176_TUNER_STATUS_RESPONSE_VCO_CODE_SHIFT );
        }
    }
exit:
    return error_code;
}
#endif /* SI2176_TUNER_STATUS_CMD */
#ifdef SI2176_TUNER_TUNE_FREQ_CMD
/*---------------------------------------------------*/
/* SI2176_TUNER_TUNE_FREQ COMMAND                  */
/*---------------------------------------------------*/
unsigned char si2176_tuner_tune_freq(struct i2c_client *si2176,
        unsigned char   mode,
        unsigned long   freq,
        si2176_cmdreplyobj_t *rsp)
{
    unsigned char error_code = 0;
    unsigned char cmdbytebuffer[8];
    unsigned char rspbytebuffer[1];

#ifdef DEBUG_RANGE_CHECK
    if ( (mode > SI2176_TUNER_TUNE_FREQ_CMD_MODE_MAX)
            || (freq > SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MAX)  || (freq < SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MIN) )
        return ERROR_SI2176_PARAMETER_OUT_OF_RANGE;
#endif /* DEBUG_RANGE_CHECK */

    error_code = si2176_pollforcts(si2176);
    if (error_code)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, error_code);
        goto exit;
    }

    cmdbytebuffer[0] = SI2176_TUNER_TUNE_FREQ_CMD;
    cmdbytebuffer[1] = (unsigned char) ( ( mode & SI2176_TUNER_TUNE_FREQ_CMD_MODE_MASK ) << SI2176_TUNER_TUNE_FREQ_CMD_MODE_LSB);
    cmdbytebuffer[2] = (unsigned char)0x00;
    cmdbytebuffer[3] = (unsigned char)0x00;
    cmdbytebuffer[4] = (unsigned char) ( ( freq & SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MASK ) << SI2176_TUNER_TUNE_FREQ_CMD_FREQ_LSB);
    cmdbytebuffer[5] = (unsigned char) ((( freq & SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MASK ) << SI2176_TUNER_TUNE_FREQ_CMD_FREQ_LSB)>>8);
    cmdbytebuffer[6] = (unsigned char) ((( freq & SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MASK ) << SI2176_TUNER_TUNE_FREQ_CMD_FREQ_LSB)>>16);
    cmdbytebuffer[7] = (unsigned char) ((( freq & SI2176_TUNER_TUNE_FREQ_CMD_FREQ_MASK ) << SI2176_TUNER_TUNE_FREQ_CMD_FREQ_LSB)>>24);

    if (si2176_writecommandbytes(si2176, 8, cmdbytebuffer) != 8)
    {
        error_code = ERROR_SI2176_SENDING_COMMAND;
        pr_info("%s: write command byte error:%d!!!!\n", __func__, error_code);
    }

    if (!error_code)
    {
        error_code = si2176_pollforresponse(si2176, 1, 1, rspbytebuffer, &reply);
        if (error_code)
            pr_info("%s: poll response error:%d!!!!\n", __func__, error_code);
        rsp->tuner_tune_freq.status = &reply;
    }
exit:
    return error_code;
}
#endif /* SI2176_TUNER_TUNE_FREQ_CMD */
/* _commands_insertion_point */

/* _send_command2_insertion_start */

/* --------------------------------------------*/
/* SEND_COMMAND2 FUNCTION                      */
/* --------------------------------------------*/
unsigned char si2176_sendcommand(struct i2c_client *si2176, int cmd, si2176_cmdobj_t *c, si2176_cmdreplyobj_t *rsp)
{
    switch (cmd)
    {
#ifdef SI2176_AGC_OVERRIDE_CMD
        case SI2176_AGC_OVERRIDE_CMD:
            return si2176_agc_override(si2176, c->agc_override.force_max_gain, c->agc_override.force_top_gain, rsp);
        break;
#endif /*     SI2176_AGC_OVERRIDE_CMD */
#ifdef SI2176_ATV_CW_TEST_CMD
        case SI2176_ATV_CW_TEST_CMD:
            return si2176_atv_cw_test(si2176, c->atv_cw_test.pc_lock, rsp);
        break;
#endif /*     SI2176_ATV_CW_TEST_CMD */
#ifdef SI2176_ATV_RESTART_CMD
        case SI2176_ATV_RESTART_CMD:
            return si2176_atv_restart(si2176, c->atv_restart.mode, rsp);
        break;
#endif /*     SI2176_ATV_RESTART_CMD */
#ifdef SI2176_ATV_STATUS_CMD
        case SI2176_ATV_STATUS_CMD:
            return si2176_atv_status(si2176, c->atv_status.intack, rsp);
        break;
#endif /*     SI2176_ATV_STATUS_CMD */
#ifdef SI2176_CONFIG_PINS_CMD
        case SI2176_CONFIG_PINS_CMD:
            return si2176_config_pins(si2176, c->config_pins.gpio1_mode, c->config_pins.gpio1_read, c->config_pins.gpio2_mode, c->config_pins.gpio2_read, c->config_pins.gpio3_mode, c->config_pins.gpio3_read, c->config_pins.bclk1_mode, c->config_pins.bclk1_read, c->config_pins.xout_mode, rsp);
        break;
#endif /*     SI2176_CONFIG_PINS_CMD */
#ifdef SI2176_EXIT_BOOTLOADER_CMD
        case SI2176_EXIT_BOOTLOADER_CMD:
            return si2176_exit_bootloader(si2176, c->exit_bootloader.func, c->exit_bootloader.ctsien, rsp);
        break;
#endif /*     SI2176_EXIT_BOOTLOADER_CMD */
#ifdef SI2176_FINE_TUNE_CMD
        case SI2176_FINE_TUNE_CMD:
            return si2176_fine_tune(si2176, c->fine_tune.reserved, c->fine_tune.offset_500hz, rsp);
        break;
#endif /*     SI2176_FINE_TUNE_CMD */
#ifdef SI2176_GET_PROPERTY_CMD
        case SI2176_GET_PROPERTY_CMD:
            return si2176_get_property(si2176, c->get_property.reserved, c->get_property.prop, rsp);
        break;
#endif /*     SI2176_GET_PROPERTY_CMD */
#ifdef SI2176_GET_REV_CMD
        case SI2176_GET_REV_CMD:
            return si2176_get_rev(si2176, rsp);
        break;
#endif /*     SI2176_GET_REV_CMD */
#ifdef SI2176_PART_INFO_CMD
        case SI2176_PART_INFO_CMD:
            return si2176_part_info(si2176, rsp);
        break;
#endif /*     SI2176_PART_INFO_CMD */
#ifdef SI2176_POWER_DOWN_CMD
        case SI2176_POWER_DOWN_CMD:
            return si2176_power_down(si2176, rsp);
        break;
#endif /*     SI2176_POWER_DOWN_CMD */
#ifdef SI2176_POWER_UP_CMD
        case SI2176_POWER_UP_CMD:
            return si2176_power_up(si2176, c->power_up.subcode, c->power_up.reserved1, c->power_up.reserved2, c->power_up.reserved3, c->power_up.clock_mode, c->power_up.clock_freq, c->power_up.addr_mode, c->power_up.func, c->power_up.ctsien, c->power_up.wake_up, rsp);
        break;
#endif /*     SI2176_POWER_UP_CMD */
#ifdef SI2176_SET_PROPERTY_CMD
        case SI2176_SET_PROPERTY_CMD:
            return si2176_set_property(si2176, c->set_property.reserved, c->set_property.prop, c->set_property.data, rsp);
        break;
#endif /*     SI2176_SET_PROPERTY_CMD */
#ifdef SI2176_STANDBY_CMD
        case SI2176_STANDBY_CMD:
            return si2176_standby(si2176, rsp);
        break;
#endif /*     SI2176_STANDBY_CMD */
#ifdef SI2176_TUNER_STATUS_CMD
        case SI2176_TUNER_STATUS_CMD:
            return si2176_tuner_status(si2176, c->tuner_status.intack, rsp);
        break;
#endif /*     SI2176_TUNER_STATUS_CMD */
#ifdef SI2176_TUNER_TUNE_FREQ_CMD
        case SI2176_TUNER_TUNE_FREQ_CMD:
            return si2176_tuner_tune_freq(si2176, c->tuner_tune_freq.mode, c->tuner_tune_freq.freq, rsp);
        break;
#endif /*     SI2176_TUNER_TUNE_FREQ_CMD */
        default :
        break;
    }
    return 0;
}
/* _send_command2_insertion_point */

/***********************************************************************************************************************
  si2176_setproperty function
  Use:        property set function
              Used to call L1_SET_PROPERTY with the property Id and data provided.
  Comments:   This is a way to make sure CTS is polled when setting a property
  Parameter: *api     the SI2176 context
  Parameter: waitforcts flag to wait for a CTS before issuing the property command
  Parameter: waitforresponse flag to wait for a CTS after issuing the property command
  Parameter: prop     the property Id
  Parameter: data     the property bytes
  Returns:    0 if no error, an error code otherwise
 ***********************************************************************************************************************/
static unsigned char si2176_setproperty(struct i2c_client *si2176, unsigned int prop, int  data, si2176_cmdreplyobj_t *rsp)
{
    unsigned char  reserved          = 0;
    return si2176_set_property(si2176, reserved, prop, data, rsp);
}

/***********************************************************************************************************************
  si2176_getproperty function
  Use:        property get function
              Used to call L1_GET_PROPERTY with the property Id provided.
  Comments:   This is a way to make sure CTS is polled when retrieving a property
  Parameter: *api     the SI2176 context
  Parameter: waitforcts flag to wait for a CTS before issuing the property command
  Parameter: waitforresponse flag to wait for a CTS after issuing the property command
  Parameter: prop     the property Id
  Parameter: *data    a buffer to store the property bytes into
  Returns:    0 if no error, an error code otherwise
 ***********************************************************************************************************************/
static unsigned char si2176_getproperty(struct i2c_client *si2176, unsigned int prop, int *data, si2176_cmdreplyobj_t *rsp)
{
    unsigned char reserved = 0;
    unsigned char res;
    res = si2176_get_property(si2176, reserved, prop, rsp);
    *data = rsp->get_property.data;
    return res;
}

/* _set_property2_insertion_start */

/* --------------------------------------------*/
/* SET_PROPERTY2 FUNCTION                      */
/* --------------------------------------------*/
unsigned char si2176_sendproperty(struct i2c_client *si2176, unsigned int prop, si2176_propobj_t *p, si2176_cmdreplyobj_t *rsp)
{
    int data = 0;
    switch (prop)
    {
#ifdef SI2176_ATV_AFC_RANGE_PROP
        case SI2176_ATV_AFC_RANGE_PROP:
            data = (p->atv_afc_range.range_khz & SI2176_ATV_AFC_RANGE_PROP_RANGE_KHZ_MASK) << SI2176_ATV_AFC_RANGE_PROP_RANGE_KHZ_LSB ;
        break;
#endif /*     SI2176_ATV_AFC_RANGE_PROP */
#ifdef SI2176_ATV_AF_OUT_PROP
        case SI2176_ATV_AF_OUT_PROP:
            data = (p->atv_af_out.volume & SI2176_ATV_AF_OUT_PROP_VOLUME_MASK) << SI2176_ATV_AF_OUT_PROP_VOLUME_LSB ;
        break;
#endif /*     SI2176_ATV_AF_OUT_PROP */
#ifdef SI2176_ATV_AGC_SPEED_PROP
        case SI2176_ATV_AGC_SPEED_PROP:
            data = (p->atv_agc_speed.if_agc_speed & SI2176_ATV_AGC_SPEED_PROP_IF_AGC_SPEED_MASK) << SI2176_ATV_AGC_SPEED_PROP_IF_AGC_SPEED_LSB ;
        break;
#endif /*     SI2176_ATV_AGC_SPEED_PROP */
#ifdef SI2176_ATV_AUDIO_MODE_PROP
        case SI2176_ATV_AUDIO_MODE_PROP:
            data = (p->atv_audio_mode.audio_sys  & SI2176_ATV_AUDIO_MODE_PROP_AUDIO_SYS_MASK ) << SI2176_ATV_AUDIO_MODE_PROP_AUDIO_SYS_LSB  |
                   (p->atv_audio_mode.demod_mode & SI2176_ATV_AUDIO_MODE_PROP_DEMOD_MODE_MASK) << SI2176_ATV_AUDIO_MODE_PROP_DEMOD_MODE_LSB  |
                   (p->atv_audio_mode.chan_bw    & SI2176_ATV_AUDIO_MODE_PROP_CHAN_BW_MASK   ) << SI2176_ATV_AUDIO_MODE_PROP_CHAN_BW_LSB ;
        break;
#endif /*     SI2176_ATV_AUDIO_MODE_PROP */
#ifdef SI2176_ATV_CVBS_OUT_PROP
        case SI2176_ATV_CVBS_OUT_PROP:
            data = (p->atv_cvbs_out.offset & SI2176_ATV_CVBS_OUT_PROP_OFFSET_MASK) << SI2176_ATV_CVBS_OUT_PROP_OFFSET_LSB  |
                   (p->atv_cvbs_out.amp    & SI2176_ATV_CVBS_OUT_PROP_AMP_MASK   ) << SI2176_ATV_CVBS_OUT_PROP_AMP_LSB ;
        break;
#endif /*     SI2176_ATV_CVBS_OUT_PROP */
#ifdef SI2176_ATV_CVBS_OUT_FINE_PROP
        case SI2176_ATV_CVBS_OUT_FINE_PROP:
            data = (p->atv_cvbs_out_fine.offset & SI2176_ATV_CVBS_OUT_FINE_PROP_OFFSET_MASK) << SI2176_ATV_CVBS_OUT_FINE_PROP_OFFSET_LSB  |
                   (p->atv_cvbs_out_fine.amp    & SI2176_ATV_CVBS_OUT_FINE_PROP_AMP_MASK   ) << SI2176_ATV_CVBS_OUT_FINE_PROP_AMP_LSB ;
        break;
#endif /*     SI2176_ATV_CVBS_OUT_FINE_PROP */
#ifdef SI2176_ATV_IEN_PROP
        case SI2176_ATV_IEN_PROP:
            data = (p->atv_ien.chlien  & SI2176_ATV_IEN_PROP_CHLIEN_MASK ) << SI2176_ATV_IEN_PROP_CHLIEN_LSB  |
                   (p->atv_ien.pclien  & SI2176_ATV_IEN_PROP_PCLIEN_MASK ) << SI2176_ATV_IEN_PROP_PCLIEN_LSB  |
                   (p->atv_ien.dlien   & SI2176_ATV_IEN_PROP_DLIEN_MASK  ) << SI2176_ATV_IEN_PROP_DLIEN_LSB  |
                   (p->atv_ien.snrlien & SI2176_ATV_IEN_PROP_SNRLIEN_MASK) << SI2176_ATV_IEN_PROP_SNRLIEN_LSB  |
                   (p->atv_ien.snrhien & SI2176_ATV_IEN_PROP_SNRHIEN_MASK) << SI2176_ATV_IEN_PROP_SNRHIEN_LSB ;
        break;
#endif /*     SI2176_ATV_IEN_PROP */
#ifdef SI2176_ATV_INT_SENSE_PROP
        case SI2176_ATV_INT_SENSE_PROP:
            data = (p->atv_int_sense.chlnegen  & SI2176_ATV_INT_SENSE_PROP_CHLNEGEN_MASK ) << SI2176_ATV_INT_SENSE_PROP_CHLNEGEN_LSB  |
                   (p->atv_int_sense.pclnegen  & SI2176_ATV_INT_SENSE_PROP_PCLNEGEN_MASK ) << SI2176_ATV_INT_SENSE_PROP_PCLNEGEN_LSB  |
                   (p->atv_int_sense.dlnegen   & SI2176_ATV_INT_SENSE_PROP_DLNEGEN_MASK  ) << SI2176_ATV_INT_SENSE_PROP_DLNEGEN_LSB  |
                   (p->atv_int_sense.snrlnegen & SI2176_ATV_INT_SENSE_PROP_SNRLNEGEN_MASK) << SI2176_ATV_INT_SENSE_PROP_SNRLNEGEN_LSB  |
                   (p->atv_int_sense.snrhnegen & SI2176_ATV_INT_SENSE_PROP_SNRHNEGEN_MASK) << SI2176_ATV_INT_SENSE_PROP_SNRHNEGEN_LSB  |
                   (p->atv_int_sense.chlposen  & SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_MASK ) << SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_LSB  |
                   (p->atv_int_sense.pclposen  & SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_MASK ) << SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_LSB  |
                   (p->atv_int_sense.dlposen   & SI2176_ATV_INT_SENSE_PROP_DLPOSEN_MASK  ) << SI2176_ATV_INT_SENSE_PROP_DLPOSEN_LSB  |
                   (p->atv_int_sense.snrlposen & SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_MASK) << SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_LSB  |
                   (p->atv_int_sense.snrhposen & SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_MASK) << SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_LSB ;
        break;
#endif /*     SI2176_ATV_INT_SENSE_PROP */
#ifdef SI2176_ATV_MIN_LVL_LOCK_PROP
        case SI2176_ATV_MIN_LVL_LOCK_PROP:
            data = (p->atv_min_lvl_lock.thrs & SI2176_ATV_MIN_LVL_LOCK_PROP_THRS_MASK) << SI2176_ATV_MIN_LVL_LOCK_PROP_THRS_LSB ;
        break;
#endif /*     SI2176_ATV_MIN_LVL_LOCK_PROP */
#ifdef SI2176_ATV_RF_TOP_PROP
        case SI2176_ATV_RF_TOP_PROP:
            data = (p->atv_rf_top.atv_rf_top & SI2176_ATV_RF_TOP_PROP_ATV_RF_TOP_MASK) << SI2176_ATV_RF_TOP_PROP_ATV_RF_TOP_LSB ;
        break;
#endif /*     SI2176_ATV_RF_TOP_PROP */
#ifdef SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP
        case SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP:
            data = (p->atv_rsq_rssi_threshold.lo & SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_LO_MASK) << SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_LO_LSB  |
                   (p->atv_rsq_rssi_threshold.hi & SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_HI_MASK) << SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_HI_LSB ;
        break;
#endif /*     SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP */
#ifdef SI2176_ATV_RSQ_SNR_THRESHOLD_PROP
        case SI2176_ATV_RSQ_SNR_THRESHOLD_PROP:
            data = (p->atv_rsq_snr_threshold.lo & SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_LO_MASK) << SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_LO_LSB  |
                   (p->atv_rsq_snr_threshold.hi & SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_HI_MASK) << SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_HI_LSB ;
        break;
#endif /*     SI2176_ATV_RSQ_SNR_THRESHOLD_PROP */
#ifdef SI2176_ATV_SIF_OUT_PROP
        case SI2176_ATV_SIF_OUT_PROP:
            data = (p->atv_sif_out.offset & SI2176_ATV_SIF_OUT_PROP_OFFSET_MASK) << SI2176_ATV_SIF_OUT_PROP_OFFSET_LSB  |
                   (p->atv_sif_out.amp    & SI2176_ATV_SIF_OUT_PROP_AMP_MASK   ) << SI2176_ATV_SIF_OUT_PROP_AMP_LSB ;
        break;
#endif /*     SI2176_ATV_SIF_OUT_PROP */
#ifdef SI2176_ATV_SOUND_AGC_LIMIT_PROP
        case SI2176_ATV_SOUND_AGC_LIMIT_PROP:
            data = (p->atv_sound_agc_limit.max_gain & SI2176_ATV_SOUND_AGC_LIMIT_PROP_MAX_GAIN_MASK) << SI2176_ATV_SOUND_AGC_LIMIT_PROP_MAX_GAIN_LSB  |
                   (p->atv_sound_agc_limit.min_gain & SI2176_ATV_SOUND_AGC_LIMIT_PROP_MIN_GAIN_MASK) << SI2176_ATV_SOUND_AGC_LIMIT_PROP_MIN_GAIN_LSB ;
        break;
#endif /*     SI2176_ATV_SOUND_AGC_LIMIT_PROP */
#ifdef SI2176_ATV_VIDEO_EQUALIZER_PROP
        case SI2176_ATV_VIDEO_EQUALIZER_PROP:
            data = (p->atv_video_equalizer.slope & SI2176_ATV_VIDEO_EQUALIZER_PROP_SLOPE_MASK) << SI2176_ATV_VIDEO_EQUALIZER_PROP_SLOPE_LSB ;
        break;
#endif /*     SI2176_ATV_VIDEO_EQUALIZER_PROP */
#ifdef SI2176_ATV_VIDEO_MODE_PROP
        case SI2176_ATV_VIDEO_MODE_PROP:
            data = (p->atv_video_mode.video_sys       & SI2176_ATV_VIDEO_MODE_PROP_VIDEO_SYS_MASK      ) << SI2176_ATV_VIDEO_MODE_PROP_VIDEO_SYS_LSB  |
                   (p->atv_video_mode.color           & SI2176_ATV_VIDEO_MODE_PROP_COLOR_MASK          ) << SI2176_ATV_VIDEO_MODE_PROP_COLOR_LSB  |
                   (p->atv_video_mode.trans           & SI2176_ATV_VIDEO_MODE_PROP_TRANS_MASK          ) << SI2176_ATV_VIDEO_MODE_PROP_TRANS_LSB  |
                   (p->atv_video_mode.invert_signal   & SI2176_ATV_VIDEO_MODE_PROP_INVERT_SIGNAL_MASK  ) << SI2176_ATV_VIDEO_MODE_PROP_INVERT_SIGNAL_LSB ;
        break;
#endif /*     SI2176_ATV_VIDEO_MODE_PROP */
#ifdef SI2176_ATV_VSNR_CAP_PROP
        case SI2176_ATV_VSNR_CAP_PROP:
            data = (p->atv_vsnr_cap.atv_vsnr_cap & SI2176_ATV_VSNR_CAP_PROP_ATV_VSNR_CAP_MASK) << SI2176_ATV_VSNR_CAP_PROP_ATV_VSNR_CAP_LSB ;
        break;
#endif /*     SI2176_ATV_VSNR_CAP_PROP */
#ifdef SI2176_ATV_VSYNC_TRACKING_PROP
        case SI2176_ATV_VSYNC_TRACKING_PROP:
            data = (p->atv_vsync_tracking.min_pulses_to_lock   & SI2176_ATV_VSYNC_TRACKING_PROP_MIN_PULSES_TO_LOCK_MASK  ) << SI2176_ATV_VSYNC_TRACKING_PROP_MIN_PULSES_TO_LOCK_LSB  |
                   (p->atv_vsync_tracking.min_fields_to_unlock & SI2176_ATV_VSYNC_TRACKING_PROP_MIN_FIELDS_TO_UNLOCK_MASK) << SI2176_ATV_VSYNC_TRACKING_PROP_MIN_FIELDS_TO_UNLOCK_LSB ;
        break;
#endif /*     SI2176_ATV_VSYNC_TRACKING_PROP */
#ifdef SI2176_CRYSTAL_TRIM_PROP
        case SI2176_CRYSTAL_TRIM_PROP:
            data = (p->crystal_trim.xo_cap & SI2176_CRYSTAL_TRIM_PROP_XO_CAP_MASK) << SI2176_CRYSTAL_TRIM_PROP_XO_CAP_LSB ;
        break;
#endif /*     SI2176_CRYSTAL_TRIM_PROP */
#ifdef SI2176_DTV_LIF_FREQ_PROP
        case SI2176_DTV_LIF_FREQ_PROP:
            data = (p->dtv_lif_freq.offset & SI2176_DTV_LIF_FREQ_PROP_OFFSET_MASK) << SI2176_DTV_LIF_FREQ_PROP_OFFSET_LSB ;
        break;
#endif /*     SI2176_DTV_LIF_FREQ_PROP */
#ifdef SI2176_DTV_LIF_OUT_PROP
        case SI2176_DTV_LIF_OUT_PROP:
            data = (p->dtv_lif_out.offset & SI2176_DTV_LIF_OUT_PROP_OFFSET_MASK) << SI2176_DTV_LIF_OUT_PROP_OFFSET_LSB  |
                   (p->dtv_lif_out.amp    & SI2176_DTV_LIF_OUT_PROP_AMP_MASK   ) << SI2176_DTV_LIF_OUT_PROP_AMP_LSB ;
        break;
#endif /*     SI2176_DTV_LIF_OUT_PROP */
#ifdef SI2176_DTV_MODE_PROP
        case SI2176_DTV_MODE_PROP:
            data = (p->dtv_mode.bw              & SI2176_DTV_MODE_PROP_BW_MASK             ) << SI2176_DTV_MODE_PROP_BW_LSB  |
                   (p->dtv_mode.modulation      & SI2176_DTV_MODE_PROP_MODULATION_MASK     ) << SI2176_DTV_MODE_PROP_MODULATION_LSB  |
                   (p->dtv_mode.invert_spectrum & SI2176_DTV_MODE_PROP_INVERT_SPECTRUM_MASK) << SI2176_DTV_MODE_PROP_INVERT_SPECTRUM_LSB ;
        break;
#endif /*     SI2176_DTV_MODE_PROP */
#ifdef SI2176_DTV_RF_TOP_PROP
        case SI2176_DTV_RF_TOP_PROP:
            data = (p->dtv_rf_top.dtv_rf_top & SI2176_DTV_RF_TOP_PROP_DTV_RF_TOP_MASK) << SI2176_DTV_RF_TOP_PROP_DTV_RF_TOP_LSB ;
        break;
#endif /*     SI2176_DTV_RF_TOP_PROP */
#ifdef SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP
        case SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP:
            data = (p->dtv_rsq_rssi_threshold.lo & SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP_LO_MASK) << SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP_LO_LSB  |
                   (p->dtv_rsq_rssi_threshold.hi & SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP_HI_MASK) << SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP_HI_LSB ;
        break;
#endif /*     SI2176_DTV_RSQ_RSSI_THRESHOLD_PROP */
#ifdef SI2176_MASTER_IEN_PROP
        case SI2176_MASTER_IEN_PROP:
            data = (p->master_ien.tunien & SI2176_MASTER_IEN_PROP_TUNIEN_MASK) << SI2176_MASTER_IEN_PROP_TUNIEN_LSB  |
                   (p->master_ien.atvien & SI2176_MASTER_IEN_PROP_ATVIEN_MASK) << SI2176_MASTER_IEN_PROP_ATVIEN_LSB  |
                   (p->master_ien.dtvien & SI2176_MASTER_IEN_PROP_DTVIEN_MASK) << SI2176_MASTER_IEN_PROP_DTVIEN_LSB  |
                   (p->master_ien.errien & SI2176_MASTER_IEN_PROP_ERRIEN_MASK) << SI2176_MASTER_IEN_PROP_ERRIEN_LSB  |
                   (p->master_ien.ctsien & SI2176_MASTER_IEN_PROP_CTSIEN_MASK) << SI2176_MASTER_IEN_PROP_CTSIEN_LSB ;
        break;
#endif /*     SI2176_MASTER_IEN_PROP */
#ifdef SI2176_TUNER_BLOCKED_VCO_PROP
        case SI2176_TUNER_BLOCKED_VCO_PROP:
            data = (p->tuner_blocked_vco.vco_code & SI2176_TUNER_BLOCKED_VCO_PROP_VCO_CODE_MASK) << SI2176_TUNER_BLOCKED_VCO_PROP_VCO_CODE_LSB ;
        break;
#endif /*     SI2176_TUNER_BLOCKED_VCO_PROP */
#ifdef SI2176_TUNER_IEN_PROP
        case SI2176_TUNER_IEN_PROP:
            data = (p->tuner_ien.tcien    & SI2176_TUNER_IEN_PROP_TCIEN_MASK   ) << SI2176_TUNER_IEN_PROP_TCIEN_LSB  |
                   (p->tuner_ien.rssilien & SI2176_TUNER_IEN_PROP_RSSILIEN_MASK) << SI2176_TUNER_IEN_PROP_RSSILIEN_LSB  |
                   (p->tuner_ien.rssihien & SI2176_TUNER_IEN_PROP_RSSIHIEN_MASK) << SI2176_TUNER_IEN_PROP_RSSIHIEN_LSB ;
        break;
#endif /*     SI2176_TUNER_IEN_PROP */
#ifdef SI2176_TUNER_INT_SENSE_PROP
        case SI2176_TUNER_INT_SENSE_PROP:
            data = (p->tuner_int_sense.tcnegen    & SI2176_TUNER_INT_SENSE_PROP_TCNEGEN_MASK   ) << SI2176_TUNER_INT_SENSE_PROP_TCNEGEN_LSB  |
                   (p->tuner_int_sense.rssilnegen & SI2176_TUNER_INT_SENSE_PROP_RSSILNEGEN_MASK) << SI2176_TUNER_INT_SENSE_PROP_RSSILNEGEN_LSB  |
                   (p->tuner_int_sense.rssihnegen & SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_MASK) << SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_LSB  |
                   (p->tuner_int_sense.tcposen    & SI2176_TUNER_INT_SENSE_PROP_TCPOSEN_MASK   ) << SI2176_TUNER_INT_SENSE_PROP_TCPOSEN_LSB  |
                   (p->tuner_int_sense.rssilposen & SI2176_TUNER_INT_SENSE_PROP_RSSILPOSEN_MASK) << SI2176_TUNER_INT_SENSE_PROP_RSSILPOSEN_LSB  |
                   (p->tuner_int_sense.rssihposen & SI2176_TUNER_INT_SENSE_PROP_RSSIHPOSEN_MASK) << SI2176_TUNER_INT_SENSE_PROP_RSSIHPOSEN_LSB ;
        break;
#endif /*     SI2176_TUNER_INT_SENSE_PROP */
#ifdef SI2176_TUNER_LO_INJECTION_PROP
        case SI2176_TUNER_LO_INJECTION_PROP:
            data = (p->tuner_lo_injection.band_1 & SI2176_TUNER_LO_INJECTION_PROP_BAND_1_MASK) << SI2176_TUNER_LO_INJECTION_PROP_BAND_1_LSB  |
                   (p->tuner_lo_injection.band_2 & SI2176_TUNER_LO_INJECTION_PROP_BAND_2_MASK) << SI2176_TUNER_LO_INJECTION_PROP_BAND_2_LSB  |
                   (p->tuner_lo_injection.band_3 & SI2176_TUNER_LO_INJECTION_PROP_BAND_3_MASK) << SI2176_TUNER_LO_INJECTION_PROP_BAND_3_LSB  |
                   (p->tuner_lo_injection.band_4 & SI2176_TUNER_LO_INJECTION_PROP_BAND_4_MASK) << SI2176_TUNER_LO_INJECTION_PROP_BAND_4_LSB  |
                   (p->tuner_lo_injection.band_5 & SI2176_TUNER_LO_INJECTION_PROP_BAND_5_MASK) << SI2176_TUNER_LO_INJECTION_PROP_BAND_5_LSB ;
        break;
#endif /*     SI2176_TUNER_LO_INJECTION_PROP */
        default :
        break;
    }
    return si2176_setproperty(si2176, prop , data, rsp);
}
/* _set_property2_insertion_point */

/* _get_property2_insertion_start */

/* --------------------------------------------*/
/* GET_PROPERTY2 FUNCTION                       */
/* --------------------------------------------*/
unsigned char si2176_receiveproperty(struct i2c_client *si2176, unsigned int prop, si2176_propobj_t *p, si2176_cmdreplyobj_t *rsp)
{
    int data, res;

    res = si2176_getproperty(si2176, prop, &data, rsp);

    if (res!=NO_SI2176_ERROR) return res;
    switch (prop)
    {
#ifdef SI2176_ATV_AFC_RANGE_PROP
        case SI2176_ATV_AFC_RANGE_PROP:
            p->atv_afc_range.range_khz = (data >> SI2176_ATV_AFC_RANGE_PROP_RANGE_KHZ_LSB) & SI2176_ATV_AFC_RANGE_PROP_RANGE_KHZ_MASK;
        break;
#endif /*     SI2176_ATV_AFC_RANGE_PROP */
#ifdef SI2176_ATV_AF_OUT_PROP
        case SI2176_ATV_AF_OUT_PROP:
            p->atv_af_out.volume = (data >> SI2176_ATV_AF_OUT_PROP_VOLUME_LSB) & SI2176_ATV_AF_OUT_PROP_VOLUME_MASK;
        break;
#endif /*     SI2176_ATV_AF_OUT_PROP */
#ifdef SI2176_ATV_AGC_SPEED_PROP
        case SI2176_ATV_AGC_SPEED_PROP:
            p->atv_agc_speed.if_agc_speed = (data >> SI2176_ATV_AGC_SPEED_PROP_IF_AGC_SPEED_LSB) & SI2176_ATV_AGC_SPEED_PROP_IF_AGC_SPEED_MASK;
        break;
#endif /*     SI2176_ATV_AGC_SPEED_PROP */
#ifdef SI2176_ATV_AUDIO_MODE_PROP
        case SI2176_ATV_AUDIO_MODE_PROP:
            p->atv_audio_mode.audio_sys  = (data >> SI2176_ATV_AUDIO_MODE_PROP_AUDIO_SYS_LSB ) & SI2176_ATV_AUDIO_MODE_PROP_AUDIO_SYS_MASK;
            p->atv_audio_mode.demod_mode = (data >> SI2176_ATV_AUDIO_MODE_PROP_DEMOD_MODE_LSB) & SI2176_ATV_AUDIO_MODE_PROP_DEMOD_MODE_MASK;
            p->atv_audio_mode.chan_bw    = (data >> SI2176_ATV_AUDIO_MODE_PROP_CHAN_BW_LSB   ) & SI2176_ATV_AUDIO_MODE_PROP_CHAN_BW_MASK;
        break;
#endif /*     SI2176_ATV_AUDIO_MODE_PROP */
#ifdef SI2176_ATV_CVBS_OUT_PROP
        case SI2176_ATV_CVBS_OUT_PROP:
            p->atv_cvbs_out.offset = (data >> SI2176_ATV_CVBS_OUT_PROP_OFFSET_LSB) & SI2176_ATV_CVBS_OUT_PROP_OFFSET_MASK;
            p->atv_cvbs_out.amp    = (data >> SI2176_ATV_CVBS_OUT_PROP_AMP_LSB   ) & SI2176_ATV_CVBS_OUT_PROP_AMP_MASK;
        break;
#endif /*     SI2176_ATV_CVBS_OUT_PROP */
#ifdef SI2176_ATV_CVBS_OUT_FINE_PROP
        case SI2176_ATV_CVBS_OUT_FINE_PROP:
            p->atv_cvbs_out_fine.offset = (data >> SI2176_ATV_CVBS_OUT_FINE_PROP_OFFSET_LSB) & SI2176_ATV_CVBS_OUT_FINE_PROP_OFFSET_MASK;
            p->atv_cvbs_out_fine.amp    = (data >> SI2176_ATV_CVBS_OUT_FINE_PROP_AMP_LSB   ) & SI2176_ATV_CVBS_OUT_FINE_PROP_AMP_MASK;
        break;
#endif /*     SI2176_ATV_CVBS_OUT_FINE_PROP */
#ifdef SI2176_ATV_IEN_PROP
        case SI2176_ATV_IEN_PROP:
            p->atv_ien.chlien  = (data >> SI2176_ATV_IEN_PROP_CHLIEN_LSB ) & SI2176_ATV_IEN_PROP_CHLIEN_MASK;
            p->atv_ien.pclien  = (data >> SI2176_ATV_IEN_PROP_PCLIEN_LSB ) & SI2176_ATV_IEN_PROP_PCLIEN_MASK;
            p->atv_ien.dlien   = (data >> SI2176_ATV_IEN_PROP_DLIEN_LSB  ) & SI2176_ATV_IEN_PROP_DLIEN_MASK;
            p->atv_ien.snrlien = (data >> SI2176_ATV_IEN_PROP_SNRLIEN_LSB) & SI2176_ATV_IEN_PROP_SNRLIEN_MASK;
            p->atv_ien.snrhien = (data >> SI2176_ATV_IEN_PROP_SNRHIEN_LSB) & SI2176_ATV_IEN_PROP_SNRHIEN_MASK;
        break;
#endif /*     SI2176_ATV_IEN_PROP */
#ifdef SI2176_ATV_INT_SENSE_PROP
        case SI2176_ATV_INT_SENSE_PROP:
            p->atv_int_sense.chlnegen  = (data >> SI2176_ATV_INT_SENSE_PROP_CHLNEGEN_LSB ) & SI2176_ATV_INT_SENSE_PROP_CHLNEGEN_MASK;
            p->atv_int_sense.pclnegen  = (data >> SI2176_ATV_INT_SENSE_PROP_PCLNEGEN_LSB ) & SI2176_ATV_INT_SENSE_PROP_PCLNEGEN_MASK;
            p->atv_int_sense.dlnegen   = (data >> SI2176_ATV_INT_SENSE_PROP_DLNEGEN_LSB  ) & SI2176_ATV_INT_SENSE_PROP_DLNEGEN_MASK;
            p->atv_int_sense.snrlnegen = (data >> SI2176_ATV_INT_SENSE_PROP_SNRLNEGEN_LSB) & SI2176_ATV_INT_SENSE_PROP_SNRLNEGEN_MASK;
            p->atv_int_sense.snrhnegen = (data >> SI2176_ATV_INT_SENSE_PROP_SNRHNEGEN_LSB) & SI2176_ATV_INT_SENSE_PROP_SNRHNEGEN_MASK;
            p->atv_int_sense.chlposen  = (data >> SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_LSB ) & SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_MASK;
            p->atv_int_sense.pclposen  = (data >> SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_LSB ) & SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_MASK;
            p->atv_int_sense.dlposen   = (data >> SI2176_ATV_INT_SENSE_PROP_DLPOSEN_LSB  ) & SI2176_ATV_INT_SENSE_PROP_DLPOSEN_MASK;
            p->atv_int_sense.snrlposen = (data >> SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_LSB) & SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_MASK;
            p->atv_int_sense.snrhposen = (data >> SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_LSB) & SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_MASK;
        break;
#endif /*     SI2176_ATV_INT_SENSE_PROP */
#ifdef SI2176_ATV_MIN_LVL_LOCK_PROP
        case SI2176_ATV_MIN_LVL_LOCK_PROP:
            p->atv_min_lvl_lock.thrs = (data >> SI2176_ATV_MIN_LVL_LOCK_PROP_THRS_LSB) & SI2176_ATV_MIN_LVL_LOCK_PROP_THRS_MASK;
        break;
#endif /*     SI2176_ATV_MIN_LVL_LOCK_PROP */
#ifdef SI2176_ATV_RF_TOP_PROP
        case SI2176_ATV_RF_TOP_PROP:
            p->atv_rf_top.atv_rf_top = (data >> SI2176_ATV_RF_TOP_PROP_ATV_RF_TOP_LSB) & SI2176_ATV_RF_TOP_PROP_ATV_RF_TOP_MASK;
        break;
#endif /*     SI2176_ATV_RF_TOP_PROP */
#ifdef SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP
        case SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP:
            p->atv_rsq_rssi_threshold.lo = (data >> SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_LO_LSB) & SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_LO_MASK;
            p->atv_rsq_rssi_threshold.hi = (data >> SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_HI_LSB) & SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP_HI_MASK;
        break;
#endif /*     SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP */
#ifdef SI2176_ATV_RSQ_SNR_THRESHOLD_PROP
        case SI2176_ATV_RSQ_SNR_THRESHOLD_PROP:
            p->atv_rsq_snr_threshold.lo = (data >> SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_LO_LSB) & SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_LO_MASK;
            p->atv_rsq_snr_threshold.hi = (data >> SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_HI_LSB) & SI2176_ATV_RSQ_SNR_THRESHOLD_PROP_HI_MASK;
        break;
#endif /*     SI2176_ATV_RSQ_SNR_THRESHOLD_PROP */
#ifdef SI2176_ATV_SIF_OUT_PROP
        case SI2176_ATV_SIF_OUT_PROP:
            p->atv_sif_out.offset = (data >> SI2176_ATV_SIF_OUT_PROP_OFFSET_LSB) & SI2176_ATV_SIF_OUT_PROP_OFFSET_MASK;
            p->atv_sif_out.amp    = (data >> SI2176_ATV_SIF_OUT_PROP_AMP_LSB   ) & SI2176_ATV_SIF_OUT_PROP_AMP_MASK;
        break;
#endif /*     SI2176_ATV_SIF_OUT_PROP */
#ifdef SI2176_ATV_SOUND_AGC_LIMIT_PROP
        case SI2176_ATV_SOUND_AGC_LIMIT_PROP:
            p->atv_sound_agc_limit.max_gain = (data >> SI2176_ATV_SOUND_AGC_LIMIT_PROP_MAX_GAIN_LSB) & SI2176_ATV_SOUND_AGC_LIMIT_PROP_MAX_GAIN_MASK;
            p->atv_sound_agc_limit.min_gain = (data >> SI2176_ATV_SOUND_AGC_LIMIT_PROP_MIN_GAIN_LSB) & SI2176_ATV_SOUND_AGC_LIMIT_PROP_MIN_GAIN_MASK;
        break;
#endif /*     SI2176_ATV_SOUND_AGC_LIMIT_PROP */
#ifdef SI2176_ATV_VIDEO_EQUALIZER_PROP
        case SI2176_ATV_VIDEO_EQUALIZER_PROP:
            p->atv_video_equalizer.slope = (data >> SI2176_ATV_VIDEO_EQUALIZER_PROP_SLOPE_LSB) & SI2176_ATV_VIDEO_EQUALIZER_PROP_SLOPE_MASK;
        break;
#endif /*     SI2176_ATV_VIDEO_EQUALIZER_PROP */
#ifdef SI2176_ATV_VIDEO_MODE_PROP
        case SI2176_ATV_VIDEO_MODE_PROP:
            p->atv_video_mode.video_sys       = (data >> SI2176_ATV_VIDEO_MODE_PROP_VIDEO_SYS_LSB      ) & SI2176_ATV_VIDEO_MODE_PROP_VIDEO_SYS_MASK;
            p->atv_video_mode.color           = (data >> SI2176_ATV_VIDEO_MODE_PROP_COLOR_LSB          ) & SI2176_ATV_VIDEO_MODE_PROP_COLOR_MASK;
            p->atv_video_mode.trans           = (data >> SI2176_ATV_VIDEO_MODE_PROP_TRANS_LSB          ) & SI2176_ATV_VIDEO_MODE_PROP_TRANS_MASK;
            p->atv_video_mode.invert_signal   = (data >> SI2176_ATV_VIDEO_MODE_PROP_INVERT_SIGNAL_LSB  ) & SI2176_ATV_VIDEO_MODE_PROP_INVERT_SIGNAL_MASK;
        break;
#endif /*     SI2176_ATV_VIDEO_MODE_PROP */
#ifdef SI2176_ATV_VSNR_CAP_PROP
        case SI2176_ATV_VSNR_CAP_PROP:
            p->atv_vsnr_cap.atv_vsnr_cap = (data >> SI2176_ATV_VSNR_CAP_PROP_ATV_VSNR_CAP_LSB) & SI2176_ATV_VSNR_CAP_PROP_ATV_VSNR_CAP_MASK;
        break;
#endif /*     SI2176_ATV_VSNR_CAP_PROP */
#ifdef SI2176_ATV_VSYNC_TRACKING_PROP
        case SI2176_ATV_VSYNC_TRACKING_PROP:
            p->atv_vsync_tracking.min_pulses_to_lock   = (data >> SI2176_ATV_VSYNC_TRACKING_PROP_MIN_PULSES_TO_LOCK_LSB  ) & SI2176_ATV_VSYNC_TRACKING_PROP_MIN_PULSES_TO_LOCK_MASK;
            p->atv_vsync_tracking.min_fields_to_unlock = (data >> SI2176_ATV_VSYNC_TRACKING_PROP_MIN_FIELDS_TO_UNLOCK_LSB) & SI2176_ATV_VSYNC_TRACKING_PROP_MIN_FIELDS_TO_UNLOCK_MASK;
        break;
#endif /*     SI2176_ATV_VSYNC_TRACKING_PROP */
#ifdef SI2176_CRYSTAL_TRIM_PROP
        case SI2176_CRYSTAL_TRIM_PROP:
            p->crystal_trim.xo_cap = (data >> SI2176_CRYSTAL_TRIM_PROP_XO_CAP_LSB) & SI2176_CRYSTAL_TRIM_PROP_XO_CAP_MASK;
        break;
#endif /*     SI2176_CRYSTAL_TRIM_PROP */
#ifdef SI2176_MASTER_IEN_PROP
        case SI2176_MASTER_IEN_PROP:
            p->master_ien.tunien = (data >> SI2176_MASTER_IEN_PROP_TUNIEN_LSB) & SI2176_MASTER_IEN_PROP_TUNIEN_MASK;
            p->master_ien.atvien = (data >> SI2176_MASTER_IEN_PROP_ATVIEN_LSB) & SI2176_MASTER_IEN_PROP_ATVIEN_MASK;
            p->master_ien.dtvien = (data >> SI2176_MASTER_IEN_PROP_DTVIEN_LSB) & SI2176_MASTER_IEN_PROP_DTVIEN_MASK;
            p->master_ien.errien = (data >> SI2176_MASTER_IEN_PROP_ERRIEN_LSB) & SI2176_MASTER_IEN_PROP_ERRIEN_MASK;
            p->master_ien.ctsien = (data >> SI2176_MASTER_IEN_PROP_CTSIEN_LSB) & SI2176_MASTER_IEN_PROP_CTSIEN_MASK;
        break;
#endif /*     SI2176_MASTER_IEN_PROP */
#ifdef SI2176_TUNER_BLOCKED_VCO_PROP
        case SI2176_TUNER_BLOCKED_VCO_PROP:
            p->tuner_blocked_vco.vco_code = (data >> SI2176_TUNER_BLOCKED_VCO_PROP_VCO_CODE_LSB) & SI2176_TUNER_BLOCKED_VCO_PROP_VCO_CODE_MASK;
        break;
#endif /*     SI2176_TUNER_BLOCKED_VCO_PROP */
#ifdef SI2176_TUNER_IEN_PROP
        case SI2176_TUNER_IEN_PROP:
            p->tuner_ien.tcien    = (data >> SI2176_TUNER_IEN_PROP_TCIEN_LSB   ) & SI2176_TUNER_IEN_PROP_TCIEN_MASK;
            p->tuner_ien.rssilien = (data >> SI2176_TUNER_IEN_PROP_RSSILIEN_LSB) & SI2176_TUNER_IEN_PROP_RSSILIEN_MASK;
            p->tuner_ien.rssihien = (data >> SI2176_TUNER_IEN_PROP_RSSIHIEN_LSB) & SI2176_TUNER_IEN_PROP_RSSIHIEN_MASK;
        break;
#endif /*     SI2176_TUNER_IEN_PROP */
#ifdef SI2176_TUNER_INT_SENSE_PROP
        case SI2176_TUNER_INT_SENSE_PROP:
            p->tuner_int_sense.tcnegen    = (data >> SI2176_TUNER_INT_SENSE_PROP_TCNEGEN_LSB   ) & SI2176_TUNER_INT_SENSE_PROP_TCNEGEN_MASK;
            p->tuner_int_sense.rssilnegen = (data >> SI2176_TUNER_INT_SENSE_PROP_RSSILNEGEN_LSB) & SI2176_TUNER_INT_SENSE_PROP_RSSILNEGEN_MASK;
            p->tuner_int_sense.rssihnegen = (data >> SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_LSB) & SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_MASK;
            p->tuner_int_sense.tcposen    = (data >> SI2176_TUNER_INT_SENSE_PROP_TCPOSEN_LSB   ) & SI2176_TUNER_INT_SENSE_PROP_TCPOSEN_MASK;
            p->tuner_int_sense.rssilposen = (data >> SI2176_TUNER_INT_SENSE_PROP_RSSILPOSEN_LSB) & SI2176_TUNER_INT_SENSE_PROP_RSSILPOSEN_MASK;
            p->tuner_int_sense.rssihposen = (data >> SI2176_TUNER_INT_SENSE_PROP_RSSIHPOSEN_LSB) & SI2176_TUNER_INT_SENSE_PROP_RSSIHPOSEN_MASK;
        break;
#endif /*     SI2176_TUNER_INT_SENSE_PROP */
#ifdef SI2176_TUNER_LO_INJECTION_PROP
        case SI2176_TUNER_LO_INJECTION_PROP:
            p->tuner_lo_injection.band_1 = (data >> SI2176_TUNER_LO_INJECTION_PROP_BAND_1_LSB) & SI2176_TUNER_LO_INJECTION_PROP_BAND_1_MASK;
            p->tuner_lo_injection.band_2 = (data >> SI2176_TUNER_LO_INJECTION_PROP_BAND_2_LSB) & SI2176_TUNER_LO_INJECTION_PROP_BAND_2_MASK;
            p->tuner_lo_injection.band_3 = (data >> SI2176_TUNER_LO_INJECTION_PROP_BAND_3_LSB) & SI2176_TUNER_LO_INJECTION_PROP_BAND_3_MASK;
            p->tuner_lo_injection.band_4 = (data >> SI2176_TUNER_LO_INJECTION_PROP_BAND_4_LSB) & SI2176_TUNER_LO_INJECTION_PROP_BAND_4_MASK;
            p->tuner_lo_injection.band_5 = (data >> SI2176_TUNER_LO_INJECTION_PROP_BAND_5_LSB) & SI2176_TUNER_LO_INJECTION_PROP_BAND_5_MASK;
        break;
#endif /*     SI2176_TUNER_LO_INJECTION_PROP */
        default :
        break;
    }
    return res;
}

/************************************************************************************************************************
  NAME: si2176_SetupATVDefaults
  DESCRIPTION: Setup si2176 ATV startup configuration
  This is a list of all the ATV configuration properties.   Depending on your application, only a subset may be required.
  The properties are stored in the global property structure 'prop'.  The function ATVConfig(..) must be called
  after any properties are modified.
  Parameter:  none
  Returns:    0 if successful
  Programming Guide Reference:    Flowchart A.5 (ATV Setup flowchart)

************************************************************************************************************************/
static int si2176_setupatvdefaults(si2176_propobj_t *prop)
{
	prop->atv_cvbs_out.amp                          = 90;
	prop->atv_cvbs_out.offset                       = 25;
	prop->atv_sif_out.amp                           = 60;
	prop->atv_sif_out.offset                        = 135;
	prop->atv_sound_agc_limit.min_gain              = -84;
	prop->atv_sound_agc_limit.max_gain              = 72;
	prop->atv_afc_range.range_khz                   = 1000;
	prop->atv_rf_top.atv_rf_top                     = SI2176_ATV_RF_TOP_PROP_ATV_RF_TOP_AUTO;
	prop->atv_vsync_tracking.min_pulses_to_lock     = 4;
	prop->atv_vsync_tracking.min_fields_to_unlock   = 16;
	prop->atv_vsnr_cap.atv_vsnr_cap                 = 0;
	prop->atv_cvbs_out_fine.amp                     = 100;
	prop->atv_cvbs_out_fine.offset                  = 0;
#ifdef SI2176_B30
    prop->atv_agc_speed.if_agc_speed                = 178;//patch for skyworth
#elif defined(SI2176_B2A)
	prop->atv_agc_speed.if_agc_speed                = SI2176_ATV_AGC_SPEED_PROP_IF_AGC_SPEED_AUTO;
#endif
	prop->atv_min_lvl_lock.thrs                     = 34;
	prop->atv_af_out.volume                         = SI2176_ATV_AF_OUT_PROP_VOLUME_VOLUME_MAX;
	prop->atv_rsq_rssi_threshold.hi                 = 0;
	prop->atv_rsq_rssi_threshold.lo                 = -100;//-70;
	prop->atv_rsq_snr_threshold.hi                  = 60;//40;
	prop->atv_rsq_snr_threshold.lo                  = 15;//25;
	prop->atv_video_equalizer.slope                 = 0;
	prop->atv_int_sense.chlnegen                    = SI2176_ATV_INT_SENSE_PROP_CHLNEGEN_DISABLE;
	prop->atv_int_sense.chlposen                    = SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_DISABLE;//SI2176_ATV_INT_SENSE_PROP_CHLPOSEN_ENABLE;
	prop->atv_int_sense.dlnegen                     = SI2176_ATV_INT_SENSE_PROP_DLNEGEN_DISABLE;
	prop->atv_int_sense.dlposen                     = SI2176_ATV_INT_SENSE_PROP_DLPOSEN_DISABLE;//SI2176_ATV_INT_SENSE_PROP_DLPOSEN_ENABLE;
	prop->atv_int_sense.pclnegen                    = SI2176_ATV_INT_SENSE_PROP_PCLNEGEN_DISABLE;
	prop->atv_int_sense.pclposen                    = SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_DISABLE;//SI2176_ATV_INT_SENSE_PROP_PCLPOSEN_ENABLE;
	prop->atv_int_sense.snrhnegen                   = SI2176_ATV_INT_SENSE_PROP_SNRHNEGEN_DISABLE;
	prop->atv_int_sense.snrhposen                   = SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_DISABLE;//SI2176_ATV_INT_SENSE_PROP_SNRHPOSEN_ENABLE;
	prop->atv_int_sense.snrlnegen                   = SI2176_ATV_INT_SENSE_PROP_SNRLNEGEN_DISABLE;
	prop->atv_int_sense.snrlposen                   = SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_DISABLE;//SI2176_ATV_INT_SENSE_PROP_SNRLPOSEN_ENABLE;
    prop->atv_ien.chlien                            = SI2176_ATV_IEN_PROP_CHLIEN_ENABLE;     /* enable only CHL to drive ATVINT */
    prop->atv_ien.dlien                             = SI2176_ATV_IEN_PROP_DLIEN_DISABLE;
    prop->atv_ien.pclien                            = SI2176_ATV_IEN_PROP_PCLIEN_DISABLE;
    prop->atv_ien.snrhien                           = SI2176_ATV_IEN_PROP_SNRHIEN_DISABLE;
    prop->atv_ien.snrlien                           = SI2176_ATV_IEN_PROP_SNRLIEN_DISABLE;
    prop->atv_audio_mode.audio_sys                  = SI2176_ATV_AUDIO_MODE_PROP_AUDIO_SYS_MONO;
    prop->atv_audio_mode.chan_bw                    = SI2176_ATV_AUDIO_MODE_PROP_CHAN_BW_DEFAULT;
    prop->atv_audio_mode.demod_mode                 = SI2176_ATV_AUDIO_MODE_PROP_DEMOD_MODE_FM1;
	prop->atv_video_mode.video_sys                  = SI2176_ATV_VIDEO_MODE_PROP_VIDEO_SYS_DK;
    prop->atv_video_mode.trans                      = SI2176_ATV_VIDEO_MODE_PROP_TRANS_CABLE;//SI2176_ATV_VIDEO_MODE_PROP_TRANS_TERRESTRIAL;
    prop->atv_video_mode.color                      = SI2176_ATV_VIDEO_MODE_PROP_COLOR_PAL_NTSC;

	return 0;
}
/************************************************************************************************************************
  NAME: si2176_SetupCommonDefaults
  DESCRIPTION: Setup si2176 Common startup configuration
  This is a list of all the common configuration properties.   Depending on your application, only a subset may be required.
  The properties are stored in the global property structure 'prop'.  The function CommonConfig(..) must be called
  after any of these properties are modified.
  Parameter:  none
  Returns:    0 if successful
  Programming Guide Reference:    Flowchart A.6a (Common setup flowchart)
************************************************************************************************************************/
static int si2176_setupcommondefaults(si2176_propobj_t *prop)
{
	 /**** Enable Interrupt Sources *******/
	prop->master_ien.atvien = SI2176_MASTER_IEN_PROP_ATVIEN_ON;
	prop->master_ien.ctsien = SI2176_MASTER_IEN_PROP_CTSIEN_ON;
	prop->master_ien.dtvien = SI2176_MASTER_IEN_PROP_DTVIEN_OFF;//SI2176_MASTER_IEN_PROP_DTVIEN_ON;
	prop->master_ien.errien = SI2176_MASTER_IEN_PROP_ERRIEN_OFF;//SI2176_MASTER_IEN_PROP_ERRIEN_ON;
	prop->master_ien.tunien = SI2176_MASTER_IEN_PROP_TUNIEN_ON;
	/* Crystal Trim adjustment */
	prop->crystal_trim.xo_cap = 8;
	return 0;
}
/************************************************************************************************************************
  NAME: si2176_SetupTunerDefaults
  DESCRIPTION: Setup si2176 Tuner startup configuration
  This is a list of all the Tuner configuration properties.   Depending on your application, only a subset may be required.
  The properties are stored in the global property structure 'prop'.  The function TunerConfig(..) must be called
  after any of these properties are modified.
  Parameter:  none
  Returns:    0 if successful
  Programming Guide Reference:    Flowchart A.6a (Tuner setup flowchart)
************************************************************************************************************************/
static int si2176_setuptunerdefaults(si2176_propobj_t *prop)
{

	/* Setting si2176_TUNER_IEN_PROP property */
    prop->tuner_ien.tcien               = SI2176_TUNER_IEN_PROP_TCIEN_ENABLE; /* enable only TC to drive TUNINT */
    prop->tuner_ien.rssilien            = SI2176_TUNER_IEN_PROP_RSSILIEN_ENABLE;
    prop->tuner_ien.rssihien            = SI2176_TUNER_IEN_PROP_RSSIHIEN_DISABLE;

	/* Setting si2176_TUNER_BLOCK_VCO_PROP property */
	prop->tuner_blocked_vco.vco_code    = 0x8000;

	/* Setting si2176_TUNER_INT_SENSE_PROP property */
	prop->tuner_int_sense.rssihnegen	=	SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_DISABLE;
	prop->tuner_int_sense.rssihposen	=	SI2176_TUNER_INT_SENSE_PROP_RSSIHPOSEN_ENABLE;
	prop->tuner_int_sense.rssilnegen	=	SI2176_TUNER_INT_SENSE_PROP_RSSILNEGEN_DISABLE;
	prop->tuner_int_sense.rssilposen	=	SI2176_TUNER_INT_SENSE_PROP_RSSILPOSEN_ENABLE;
	prop->tuner_int_sense.tcnegen	    =	SI2176_TUNER_INT_SENSE_PROP_RSSIHNEGEN_DISABLE;
	prop->tuner_int_sense.tcposen	    =	SI2176_TUNER_INT_SENSE_PROP_TCPOSEN_ENABLE;


   /* Setting si2176_TUNER_LO_INJECTION_PROP property */
	prop->tuner_lo_injection.band_1	    =	SI2176_TUNER_LO_INJECTION_PROP_BAND_1_HIGH_SIDE;
	prop->tuner_lo_injection.band_2	    =	SI2176_TUNER_LO_INJECTION_PROP_BAND_2_LOW_SIDE;
	prop->tuner_lo_injection.band_3	    =	SI2176_TUNER_LO_INJECTION_PROP_BAND_3_LOW_SIDE;
	prop->tuner_lo_injection.band_4	    =	SI2176_TUNER_LO_INJECTION_PROP_BAND_4_LOW_SIDE;
	prop->tuner_lo_injection.band_5	    =	SI2176_TUNER_LO_INJECTION_PROP_BAND_5_LOW_SIDE;

	return 0;
}

/************************************************************************************************************************
  NAME: si2176_ATVConfig
  DESCRIPTION: Setup si2176 ATV properties configuration
  This function will download all the ATV configuration properties stored in the global structure 'prop.
  Depending on your application, only a subset may be required to be modified.
  The function si2176_SetupATVDefaults() should be called before the first call to this function. Afterwards
  to change a property change the appropriate element in the property structure 'prop' and call this routine.
  Use the comments above the SetProperty2 calls as a guide to the parameters which are changed.
  Parameter:  Pointer to si2176 Context (I2C address)
  Returns:    I2C transaction error code, 0 if successful
  Programming Guide Reference:    Flowchart A.5 (ATV setup flowchart)
************************************************************************************************************************/
int si2176_atvconfig(struct i2c_client *si2176, si2176_propobj_t *prop, si2176_cmdreplyobj_t *rsp)
{

  /* Set ATV_CVBS_OUT property */
	//prop.atv_cvbs_out.amp,
	//prop.atv_cvbs_out.offset
   if (si2176_sendproperty(si2176, SI2176_ATV_CVBS_OUT_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_SIF_OUT property */
	//prop.atv_sif_out.amp,
	//prop.atv_sif_out.offset
   if (si2176_sendproperty(si2176, SI2176_ATV_SIF_OUT_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the si2176_ATV_SOUND_AGC_LIMIT property */
	//prop.atv_sif_out.min_gain,
	//prop.atv_sif_out.max_gain
   if (si2176_sendproperty(si2176, SI2176_ATV_SOUND_AGC_LIMIT_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }
   /* Set the ATV_AFC_RANGE property */
	//prop.atv_afc_range.range_khz
   if (si2176_sendproperty(si2176, SI2176_ATV_AFC_RANGE_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_RF_TOP property */
	//prop.atv_rf_top.atv_rf_top
   if (si2176_sendproperty(si2176, SI2176_ATV_RF_TOP_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_VSYNC_TRACKING property */
	//prop.atv_vsync_tracking.min_pulses_to_lock,
	//prop.atv_vsync_tracking.min_fields_to_unlock
   if (si2176_sendproperty(si2176, SI2176_ATV_VSYNC_TRACKING_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

	/* Set the ATV_VSNR_CAP property */
	//prop.atv_vsnr_cap.atv_vsnr_cap
   if (si2176_sendproperty(si2176, SI2176_ATV_VSNR_CAP_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_CVBS_OUT_FINE property */
	//prop.atv_cvbs_out_fine.amp,
	//prop.atv_cvbs_out_fine.offset
   if (si2176_sendproperty(si2176, SI2176_ATV_CVBS_OUT_FINE_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_AGC_SPEED property */
	//prop.atv_agc_speed.if_agc_speed
   if (si2176_sendproperty(si2176, SI2176_ATV_AGC_SPEED_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

    /* Set the ATV_MIN_LVL_LOCK property */
    //	prop.atv_min_lvl_lock.thrs
    //	prop.atv_min_lvl_lock.tol
   if (si2176_sendproperty(si2176, SI2176_ATV_MIN_LVL_LOCK_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /* Set the ATV_AF_OUT property */
	//prop.atv_af_out.volume
   if (si2176_sendproperty(si2176, SI2176_ATV_AF_OUT_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /*Set the ATV_RSSI_RSQ_THRESHOLD property */
	//prop.atv_rsq_rssi_threshold.hi,
	//prop.atv_rsq_rssi_threshold.lo
   if (si2176_sendproperty(si2176, SI2176_ATV_RSQ_RSSI_THRESHOLD_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /*Set the ATV_SNR_RSQ_THRESHOLD property */
	//prop.atv_rsq_snr_threshold.hi,
	//prop.atv_rsq_snr_threshold.lo
   if (si2176_sendproperty(si2176, SI2176_ATV_RSQ_SNR_THRESHOLD_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /*Set the ATV_VIDEO_EQUALIZER property */
	//prop.atv_video_equalizer.slope
   if (si2176_sendproperty(si2176, SI2176_ATV_VIDEO_EQUALIZER_PROP, prop, rsp) != 0)
   {
	    return ERROR_SI2176_SENDING_COMMAND;
   }

   /*Set the ATV_INT_SENSE property */
	//prop.atv_int_sense.chlnegen,
	//prop.atv_int_sense.chlposen,
	//prop.atv_int_sense.dlnegen,
	//prop.atv_int_sense.dlposen,
	//prop.atv_int_sense.pclnegen,
	//prop.atv_int_sense.pclposen,
	//prop.atv_int_sense.snrhnegen,
	//prop.atv_int_sense.snrhposen,
	//prop.atv_int_sense.snrlnegen,
	//prop.atv_int_sense.snrlposen
    if (si2176_sendproperty(si2176, SI2176_ATV_INT_SENSE_PROP, prop, rsp) != 0)
	{
	    return ERROR_SI2176_SENDING_COMMAND;
    }
  /* setup ATV_IEN_PROP  IEN properties to enable ATVINT on CHL  */

    /* prop.atv_ien.chlien,
    prop.atv_ien.pclien,
    prop.atv_ien.dlien ,
    prop.atv_ien.snrlien,
    prop.atv_ien.snrhien */
    if (si2176_sendproperty(si2176, SI2176_ATV_IEN_PROP, prop, rsp) != 0)
	{
        return ERROR_SI2176_SENDING_COMMAND;
    }

    /* Set the ATV_AUDIO_MODE property */
	/*	prop.atv_audio_mode.audio_sys,
		prop.atv_audio_mode.chan_bw,
		prop.atv_audio_mode.demod_mode  */
    if (si2176_sendproperty(si2176, SI2176_ATV_AUDIO_MODE_PROP, prop, rsp) != 0)
	{
	    return ERROR_SI2176_SENDING_COMMAND;
    }

   /* Set the ATV_VIDEO_MODE property */
	/*	prop.atv_video_mode.video_sys,
		prop.atv_video_mode.trans,
		prop.atv_video_mode.color  */
    if (si2176_sendproperty(si2176, SI2176_ATV_VIDEO_MODE_PROP, prop, rsp) != 0)
	{
	    return ERROR_SI2176_SENDING_COMMAND;
    }

    return 0;
}

/************************************************************************************************************************
  NAME: si2176_CommonConfig
  DESCRIPTION: Setup si2176 Common properties configuration
  This function will download all the DTV configuration properties stored in the global structure 'prop.
  Depending on your application, only a subset may be required to be modified.
  The function si2176_SetupCommonDefaults() should be called before the first call to this function. Afterwards
  to change a property change the appropriate element in the property structure 'prop' and call this routine.
  Use the comments above the si2176_sendproperty calls as a guide to the parameters which are changed.
  Parameter:  Pointer to si2176 Context (I2C address)
  Returns:    I2C transaction error code, 0 if successful
  Programming Guide Reference:    Flowchart A.6a (Common setup flowchart)
************************************************************************************************************************/
int si2176_commonconfig(struct i2c_client *si2176, si2176_propobj_t *prop, si2176_cmdreplyobj_t *rsp)
{

    /* Setting si2176_MASTER_IEN_PROP property */
	 /***
		 prop.master_ien.atvien,
		 prop.master_ien.ctsien,
		 prop.master_ien.dtvien,
		 prop.master_ien.errien,
		 prop.master_ien.tunien  */

    if (si2176_sendproperty(si2176, SI2176_MASTER_IEN_PROP, prop, rsp) != 0)
	{
        return ERROR_SI2176_SENDING_COMMAND;
    }

    /* Setting si2176_CRYSTAL_TRIM_PROP */
    //	prop.crystal_trim.xo_cap
    if (si2176_sendproperty(si2176, SI2176_CRYSTAL_TRIM_PROP, prop, rsp) != 0)
	{
        return ERROR_SI2176_SENDING_COMMAND;
    }

	return 0;
}
/************************************************************************************************************************
  NAME: si2176_TunerConfig
  DESCRIPTION: Setup si2176 Tuner (RF to IF analog path) properties configuration
  This function will download all the DTV configuration properties stored in the global structure 'prop.
  Depending on your application, only a subset may be required to be modified.
  The function si2176_SetupTunerDefaults() should be called before the first call to this function. Afterwards
  to change a property change the appropriate element in the property structure 'prop' and call this routine.
  Use the comments above the si2176_sendproperty calls as a guide to the parameters which are changed.
  Parameter:  Pointer to si2176 Context (I2C address)
  Returns:    I2C transaction error code, 0 if successful
  Programming Guide Reference:    Flowchart A.6a (Tuner setup flowchart)
************************************************************************************************************************/
int si2176_tunerconfig(struct i2c_client *si2176, si2176_propobj_t *prop, si2176_cmdreplyobj_t *rsp)
{
	/* Set TUNER_IEN property */
	/*	prop.tuner_ien.tcien,
		prop.tuner_ien.rssilien,
		prop.tuner_ien.rssihien */
	if (si2176_sendproperty(si2176, SI2176_TUNER_IEN_PROP, prop, rsp) != 0)
	{
		return ERROR_SI2176_SENDING_COMMAND;
	}

	/* Setting TUNER_BLOCKED_VCO property */
	/*	prop.tuner_blocked_vco.vco_code, */
	if (si2176_sendproperty(si2176, SI2176_TUNER_BLOCKED_VCO_PROP, prop, rsp) != 0)
	{
		return ERROR_SI2176_SENDING_COMMAND;
	}
	/* Setting si2176_TUNER_INT_SENSE_PROP property */
	/*	prop.tuner_int_sense.rssihnegen,
		prop.tuner_int_sense.rssihposen,
		prop.tuner_int_sense.rssilnegen,
		prop.tuner_int_sense.rssilposen,
		prop.tuner_int_sense.tcnegen,
		prop.tuner_int_sense.tcposen */

	if (si2176_sendproperty(si2176, SI2176_TUNER_INT_SENSE_PROP, prop, rsp) != 0)
	{
		return ERROR_SI2176_SENDING_COMMAND;
	}

	/* Setting si2176_TUNER_LO_INJECTION_PROP property */
	/*	prop.tuner_lo_injection.band_1,
		prop.tuner_lo_injection.band_2,
		prop.tuner_lo_injection.band_3,
		prop.tuner_lo_injection.band_4,
		prop.tuner_lo_injection.band_5 */
	if (si2176_sendproperty(si2176, SI2176_TUNER_LO_INJECTION_PROP, prop, rsp) != 0)
	{
		return ERROR_SI2176_SENDING_COMMAND;
	}


    return 0;
}

/************************************************************************************************************************
  NAME: si2176_Tune
  DESCRIPTIION: Tune si2176 in specified mode (ATV/DTV) at center frequency, wait for TUNINT and xTVINT with timeout

  Parameter:  Pointer to si2176 Context (I2C address)
  Parameter:  Mode (ATV or DTV) use si2176_TUNER_TUNE_FREQ_CMD_MODE_ATV or si2176_TUNER_TUNE_FREQ_CMD_MODE_DTV constants
  Parameter:  frequency (Hz) as a unsigned long integer
  Parameter:  rsp - commandResp structure to returns tune status info.
  Returns:    0 if channel found.  A nonzero value means either an error occurred or channel not locked.
  Programming Guide Reference:    Flowchart A.7 (Tune flowchart)
************************************************************************************************************************/
int si2176_tune(struct i2c_client *si2176, unsigned char mode, unsigned long freq, si2176_cmdreplyobj_t *rsp, si2176_common_reply_struct *common_reply)
{
    int return_code = 0,count = 0;

    if (si2176_tuner_tune_freq(si2176, mode, freq, rsp) != 0)
	{
        pr_info("%s: tuner tune freq error:%d!!!!\n", __func__, ERROR_SI2176_SENDING_COMMAND);
        return ERROR_SI2176_SENDING_COMMAND;
    }
    for (count=50; count ;count--)
	{
        return_code = si2176_pollforcts(si2176);
        if (!return_code)
            break;
        mdelay(2);
    }
    if (!count)
    {
        pr_info("%s: poll cts error:%d!!!!\n", __func__, return_code);
        return return_code;
    }
#if 0
    /* wait for TUNINT, timeout is 150ms */
    for (count=75; count ;count--)
	{
        if ((return_code = si2176_check_status(si2176, common_reply)) != 0)
            return return_code;
        if (common_reply->tunint)
            break;
        mdelay(2);
    }
    if (!count)
    {
        pr_info("%s: ERROR_SI2176_TUNINT_TIMEOUT error:%d!!!!\n", __func__, ERROR_SI2176_TUNINT_TIMEOUT);
        return ERROR_SI2176_TUNINT_TIMEOUT;
    }
    /* wait for xTVINT, timeout is 350ms for ATVINT and 6 ms for DTVINT */
    count = ((mode==SI2176_TUNER_TUNE_FREQ_CMD_MODE_ATV) ? 300 : 3);
    for (;count ;count--)
	{
        if ((return_code = si2176_check_status(si2176, common_reply)) != 0)
            return return_code;
        if ((mode==SI2176_TUNER_TUNE_FREQ_CMD_MODE_ATV) ? common_reply->atvint : common_reply->dtvint)
            break;
        mdelay(2);
    }
    if (!count)
    {
        pr_info("%s: ERROR_SI2176_XTVINT_TIMEOUT error:%d!!!!\n", __func__, ERROR_SI2176_XTVINT_TIMEOUT);
        return ERROR_SI2176_XTVINT_TIMEOUT;
    }
#endif
    return return_code;
}

/************************************************************************************************************************
  NAME: si2176_LoadVideofilter
  DESCRIPTION:        Load video filters from vidfiltTable in si2176_write_xTV_video_coeffs.h file into si2176
  Programming Guide Reference:    Flowchart A.4 (Download Video Filters flowchart)

  Parameter:  si2176 Context (I2C address)
  Parameter:  pointer to video filter table array
  Parameter:  number of lines in video filter table array (size in bytes / BYTES_PER_LINE)
  Returns:    si2176/I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_loadvideofilter(struct i2c_client *si2176, unsigned char* vidfilttable, int lines, si2176_common_reply_struct *common_reply)
{
#define BYTES_PER_LINE 8
    int line;

    /* for each 8 bytes in VIDFILT_TABLE */
    for (line = 0; line < lines; line++)
    {
        /* send that 8 byte I2C command to si2176 */
        if (si2176_api_patch(si2176, BYTES_PER_LINE, vidfilttable+BYTES_PER_LINE*line, common_reply) != 0)
        {
            return ERROR_SI2176_SENDING_COMMAND;
        }
    }
    return 0;
}
/************************************************************************************************************************
  NAME: si2176_Configure
  DESCRIPTION: Setup si2176 video filters, GPIOs/clocks, Common Properties startup, Tuner startup, ATV startup, and DTV startup.
  Parameter:  Pointer to si2176 Context (I2C address)
  Parameter:  rsp - commandResp structure buffer.
  Returns:    I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_configure(struct i2c_client *si2176, si2176_propobj_t *prop, si2176_cmdreplyobj_t *rsp, si2176_common_reply_struct *common_reply)
{
    int return_code = 0;
	if(SI2176_DEBUG)
    	pr_info("%s: start!!!\n", __func__);

    /* load ATV video filter file */
#ifdef USING_ATV_FILTER
    if ((return_code = si2176_loadvideofilter(si2176, dlif_vidfilt_table, DLIF_VIDFILT_LINES, common_reply) != 0)
        return return_code;
#endif

    /* Set the GPIO Pins using the CONFIG_PINS command*/
    if (si2176_config_pins(si2176, 		/* turn off BCLK1 and XOUT */
                           SI2176_CONFIG_PINS_CMD_GPIO1_MODE_NO_CHANGE,
                           SI2176_CONFIG_PINS_CMD_GPIO1_READ_DO_NOT_READ,
                           SI2176_CONFIG_PINS_CMD_GPIO2_MODE_NO_CHANGE,
                           SI2176_CONFIG_PINS_CMD_GPIO2_READ_DO_NOT_READ,
                           SI2176_CONFIG_PINS_CMD_GPIO3_MODE_NO_CHANGE,
                           SI2176_CONFIG_PINS_CMD_GPIO3_READ_DO_NOT_READ,
                           SI2176_CONFIG_PINS_CMD_BCLK1_MODE_DISABLE,
                           SI2176_CONFIG_PINS_CMD_BCLK1_READ_DO_NOT_READ,
                           SI2176_CONFIG_PINS_CMD_XOUT_MODE_DISABLE,
                           rsp) !=0)
    {
        pr_info("%s: config pins error:%d!!!!\n", __func__, ERROR_SI2176_SENDING_COMMAND);
        return ERROR_SI2176_SENDING_COMMAND;
    }
#if  1
    /* Set Common Properties startup configuration */
	si2176_setupcommondefaults(prop);
    if ((return_code = si2176_commonconfig(si2176, prop, rsp)) != 0)
    {
       pr_info("%s: setup command defaults error:%d!!!!\n", __func__, return_code);
       return return_code;
    }

	/* Set Tuner Properties startup configuration */
	si2176_setuptunerdefaults(prop);
    if ((return_code = si2176_tunerconfig(si2176, prop, rsp)) != 0)
    {
        pr_info("%s: setup tuner defaults error:%d!!!!\n", __func__, return_code);
        return return_code;
    }
	/* Set ATV startup configuration */
	si2176_setupatvdefaults(prop);
    if ((return_code = si2176_atvconfig(si2176, prop, rsp)) != 0)
    {
        pr_info("%s: setup atv defaults error:%d!!!!\n", __func__, return_code);
        return return_code;
    }
#endif

    return return_code;
}
/************************************************************************************************************************
  NAME: si2176_LoadFirmware
  DESCRIPTON: Load firmware from FIRMWARE_TABLE array in si2176_Firmware_x_y_build_z.h file into si2176
              Requires si2176 to be in bootloader mode after PowerUp
  Programming Guide Reference:    Flowchart A.3 (Download FW PATCH flowchart)

  Parameter:  si2176 Context (I2C address)
  Parameter:  pointer to firmware table array
  Parameter:  number of lines in firmware table array (size in bytes / BYTES_PER_LINE)
  Returns:    si2176/I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_loadfirmware(struct i2c_client *si2176, unsigned char* firmwaretable, int lines, si2176_common_reply_struct *common_reply)
{
    int return_code = 0;
    int line;

    /* for each 8 bytes in FIRMWARE_TABLE */
    for (line = 0; line < lines; line++)
    {
        /* send that 8 byte I2C command to si2176 */
        if (si2176_api_patch(si2176, 8, firmwaretable+8*line, common_reply) != 0)
        {
            return ERROR_SI2176_LOADING_FIRMWARE;
        }
    }
    return return_code;
}

/************************************************************************************************************************
  NAME: si2176_StartFirmware
  DESCRIPTION: Start si2176 firmware (put the si2176 into run mode)
  Parameter:   si2176 Context (I2C address)
  Parameter (passed by Reference): 	ExitBootloadeer Response Status byte : tunint, atvint, dtvint, err, cts
  Returns:     I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_startfirmware(struct i2c_client *si2176, si2176_cmdreplyobj_t *rsp)
{

    if (si2176_exit_bootloader(si2176, SI2176_EXIT_BOOTLOADER_CMD_FUNC_TUNER, SI2176_EXIT_BOOTLOADER_CMD_CTSIEN_OFF, rsp) != 0)
    {
        return ERROR_SI2176_STARTING_FIRMWARE;
    }

    return 0;
}
/************************************************************************************************************************
  NAME: si2176_PowerUpWithPatch
  DESCRIPTION: Send si2176 API PowerUp Command with PowerUp to bootloader,
  Check the Chip rev and part, and ROMID are compared to expected values.
  Load the Firmware Patch then Start the Firmware.
  Programming Guide Reference:    Flowchart A.2a (POWER_UP with patch flowchart)

  Parameter:  si2176 Context (I2C address)
  Returns:    si2176/I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_powerupwithpatch(struct i2c_client *si2176, si2176_cmdreplyobj_t *rsp, si2176_common_reply_struct *common_reply)
{
    int return_code = 0;

    return_code = si2176_power_up(si2176,          /* always wait for CTS prior to POWER_UP command */
                                  SI2176_POWER_UP_CMD_SUBCODE_CODE,
                                  SI2176_POWER_UP_CMD_RESERVED1_RESERVED,
                                  SI2176_POWER_UP_CMD_RESERVED2_RESERVED,
                                  SI2176_POWER_UP_CMD_RESERVED3_RESERVED,
                                  SI2176_POWER_UP_CMD_CLOCK_MODE_XTAL,
                                  SI2176_POWER_UP_CMD_CLOCK_FREQ_CLK_24MHZ,
                                  SI2176_POWER_UP_CMD_ADDR_MODE_CURRENT,
                                  SI2176_POWER_UP_CMD_FUNC_BOOTLOADER,        /* start in bootloader mode */
                                  SI2176_POWER_UP_CMD_CTSIEN_DISABLE,
                                  SI2176_POWER_UP_CMD_WAKE_UP_WAKE_UP,
                                  rsp);
    if (return_code)
        pr_info("%s: si2176_power_up error:%d!!!\n", __func__, return_code);

#if 0
    /* Get the Part Info from the chip.   This command is only valid in Bootloader mode */
    if (si2176_part_info(si2176, &rsp) != 0)
        return ERROR_SI2176_SENDING_COMMAND;
    /* Check the Chip revision, part and ROMID against expected values and report an error if incompatible */
    if (rsp.part_info.chiprev != chiprev)
        return ERROR_SI2176_INCOMPATIBLE_PART;
    /* Part Number is represented as the last 2 digits */
    if (rsp.part_info.part != part)
        return ERROR_SI2176_INCOMPATIBLE_PART;
    /* Part Major Version in ASCII */
    if (rsp.part_info.pmajor != partmajorversion)
        return ERROR_SI2176_INCOMPATIBLE_PART;

#endif
    mdelay(25);
 /* Load the Firmware */
    if ((return_code = si2176_loadfirmware(si2176, firmwaretable, NB_LINES, common_reply)) != 0)
    {
        pr_info("%s: si2176_loadfirmware error:%d!!!\n", __func__, return_code);
        return return_code;
    }

    /*Start the Firmware */
    if ((return_code = si2176_startfirmware(si2176, rsp)) != 0) /* Start firmware */
    {
        pr_info("%s: si2176_startfirmware error:%d!!!\n", __func__, return_code);
        return return_code;
    }
    mdelay(50);
    if (si2176_get_rev(si2176, rsp) != 0)
    {
        pr_info("%s: si2176_get_rev error:%d!!!\n", __func__, ERROR_SI2176_SENDING_COMMAND);
        return ERROR_SI2176_SENDING_COMMAND;
    }
    else
    {
    	if(SI2176_DEBUG)
		{
		    pr_info("%s: rsp.get_rev.pn :      %d \n", __func__, rsp->get_rev.pn);
		    pr_info("%s: rsp.get_rev.fwmajor : %d \n", __func__, rsp->get_rev.fwmajor);
		    pr_info("%s: rsp.get_rev.fwminor : %d \n", __func__, rsp->get_rev.fwminor);
		    pr_info("%s: rsp.get_rev.patch :   %d \n", __func__, rsp->get_rev.patch);
		    pr_info("%s: rsp.get_rev.cmpmajor :%d \n", __func__, rsp->get_rev.cmpmajor);
		    pr_info("%s: rsp.get_rev.cmpminor :%d \n", __func__, rsp->get_rev.cmpminor);
		    pr_info("%s: rsp.get_rev.cmpbuild :%d \n", __func__, rsp->get_rev.cmpbuild);
		    pr_info("%s: rsp.get_rev.chiprev : %d \n", __func__, (u32)rsp->get_rev.chiprev);
    	}
	}

    return return_code;
}


/************************************************************************************************************************
  NAME: si2176_Init
  DESCRIPTION:Reset and Initialize si2176
  Parameter:  si2176 Context (I2C address)
  Returns:    I2C transaction error code, 0 if successful
************************************************************************************************************************/
int si2176_init(struct i2c_client *si2176, si2176_cmdreplyobj_t *rsp, si2176_common_reply_struct *common_reply)
{
    int return_code = 0;

    /* Reset si2176 */
    /* TODO: SendRSTb requires porting to toggle the RSTb line low -> high */
    //sendrstb();

    return_code = si2176_powerupwithpatch(si2176, rsp, common_reply);
    if (return_code)		/* PowerUp into bootloader */
    {
        pr_info("%s: init si2176 error!!!\n", __func__);
    }

    /* At this point, FW is loaded and started.  Return 0*/
    return return_code;
}



